uploader 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +55 -57
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/helpers/uploader_helper.rb +3 -3
- data/app/views/uploads/_swf_javascript.html.erb +9 -6
- data/app/views/uploads/_swf_upload.html.erb +2 -2
- data/app/views/uploads/_uploadify.html.erb +3 -3
- data/{locales → config/locales}/ar.yml +0 -0
- data/{locales → config/locales}/bg.yml +0 -0
- data/{locales → config/locales}/ca.yml +0 -0
- data/{locales → config/locales}/cs.yml +0 -0
- data/{locales → config/locales}/da.yml +0 -0
- data/{locales → config/locales}/de.yml +0 -0
- data/{locales → config/locales}/el.yml +0 -0
- data/{locales → config/locales}/en.yml +0 -0
- data/{locales → config/locales}/es.yml +0 -0
- data/{locales → config/locales}/et.yml +0 -0
- data/{locales → config/locales}/fa.yml +2 -2
- data/{locales → config/locales}/fi.yml +0 -0
- data/{locales → config/locales}/fr.yml +0 -0
- data/{locales → config/locales}/gl.yml +0 -0
- data/{locales → config/locales}/hi.yml +1 -1
- data/{locales → config/locales}/hr.yml +0 -0
- data/{locales → config/locales}/hu.yml +0 -0
- data/{locales → config/locales}/id.yml +1 -1
- data/{locales → config/locales}/it.yml +0 -0
- data/{locales → config/locales}/iw.yml +0 -0
- data/{locales → config/locales}/ja.yml +0 -0
- data/{locales → config/locales}/ko.yml +2 -2
- data/{locales → config/locales}/lt.yml +0 -0
- data/{locales → config/locales}/lv.yml +0 -0
- data/{locales → config/locales}/mt.yml +0 -0
- data/{locales → config/locales}/nl.yml +0 -0
- data/{locales → config/locales}/no.yml +0 -0
- data/{locales → config/locales}/pl.yml +0 -0
- data/{locales → config/locales}/pt-PT.yml +0 -0
- data/{locales → config/locales}/ro.yml +0 -0
- data/{locales → config/locales}/ru.yml +0 -0
- data/{locales → config/locales}/sk.yml +0 -0
- data/{locales → config/locales}/sl.yml +0 -0
- data/{locales → config/locales}/sq.yml +0 -0
- data/{locales → config/locales}/sr.yml +0 -0
- data/{locales → config/locales}/sv.yml +0 -0
- data/{locales → config/locales}/th.yml +1 -1
- data/{locales → config/locales}/tl.yml +0 -0
- data/{locales → config/locales}/tr.yml +0 -0
- data/{locales → config/locales}/uk.yml +0 -0
- data/{locales → config/locales}/vi.yml +2 -2
- data/{locales → config/locales}/zh-CN.yml +0 -0
- data/{locales → config/locales}/zh-TW.yml +0 -0
- data/{locales → config/locales}/zh.yml +0 -0
- data/config/routes.rb +8 -0
- data/lib/tasks/uploader.rake +22 -0
- data/lib/uploader/config.rb +65 -0
- data/lib/uploader/engine.rb +19 -0
- data/lib/uploader/models/upload.rb +229 -0
- data/lib/uploader.rb +4 -2
- data/test/{rails_root → rails_test}/.gitignore +0 -0
- data/test/{rails_root → rails_test}/.rake_tasks +0 -0
- data/test/rails_test/Gemfile +21 -0
- data/{Gemfile.lock → test/rails_test/Gemfile.lock} +21 -1
- data/test/rails_test/README +256 -0
- data/test/{rails_root → rails_test}/Rakefile +2 -7
- data/test/{rails_root → rails_test}/app/controllers/application_controller.rb +0 -0
- data/test/rails_test/app/controllers/default_controller.rb +18 -0
- data/test/{rails_root → rails_test}/app/controllers/uploads_controller.rb +5 -2
- data/test/{rails_root → rails_test}/app/models/.keep +0 -0
- data/test/rails_test/app/models/upload.rb +38 -0
- data/test/{rails_root → rails_test}/app/models/user.rb +0 -0
- data/test/{rails_root → rails_test}/app/views/default/index.html.erb +11 -1
- data/test/rails_test/app/views/default/uploadify.html.erb +27 -0
- data/test/{rails_root → rails_test}/app/views/layouts/application.html.erb +2 -2
- data/test/{rails_root → rails_test}/config/amazon_s3.yml +0 -0
- data/test/{rails_root → rails_test}/config/application.rb +6 -12
- data/test/rails_test/config/boot.rb +13 -0
- data/test/{rails_root → rails_test}/config/database.yml +3 -11
- data/test/rails_test/config/environment.rb +5 -0
- data/test/rails_test/config/environments/development.rb +26 -0
- data/test/rails_test/config/environments/production.rb +49 -0
- data/test/rails_test/config/environments/test.rb +35 -0
- data/test/{rails_root → rails_test}/config/global_config.yml +0 -0
- data/test/{rails_root → rails_test}/config/initializers/backtrace_silencers.rb +0 -0
- data/test/{rails_root → rails_test}/config/initializers/inflections.rb +2 -2
- data/test/{rails_root → rails_test}/config/initializers/mime_types.rb +0 -0
- data/test/{rails_root → rails_test}/config/initializers/s3_credentials.rb +1 -1
- data/test/{rails_root → rails_test}/config/initializers/secret_token.rb +1 -1
- data/test/rails_test/config/initializers/session_store.rb +8 -0
- data/test/rails_test/config/locales/en.yml +5 -0
- data/test/rails_test/config/routes.rb +13 -0
- data/test/rails_test/config.ru +4 -0
- data/test/{rails_root → rails_test}/db/.keep +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090517040220_create_uploads.rb +0 -0
- data/test/{rails_root → rails_test}/db/migrate/20090602041838_create_users.rb +0 -0
- data/test/rails_test/db/seeds.rb +7 -0
- data/test/rails_test/doc/README_FOR_APP +2 -0
- data/test/{rails_root → rails_test}/features/step_definitions/webrat_steps.rb +0 -0
- data/test/{rails_root → rails_test}/features/support/env.rb +0 -0
- data/test/{rails_root → rails_test}/lib/daemons/amazonaws.rb +0 -0
- data/test/{rails_root/public/favicon.ico → rails_test/lib/tasks/.gitkeep} +0 -0
- data/test/rails_test/public/404.html +26 -0
- data/test/rails_test/public/422.html +26 -0
- data/test/rails_test/public/500.html +26 -0
- data/test/{rails_root/public/stylesheets/.keep → rails_test/public/favicon.ico} +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/excel.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file.png +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_aac.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_ai.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_avi.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_bin.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_bmp.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_cue.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_divx.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_doc.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_eps.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_flac.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_flv.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_gif.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_html.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_ical.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_indd.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_inx.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_iso.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_jpg.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_mov.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_mp3.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_mpg.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_pdf.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_php.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_png.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_pps.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_ppt.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_psd.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_qxd.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_qxp.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_raw.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_rtf.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_svg.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_tif.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_txt.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_vcf.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_wav.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_wma.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_xls.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/file_xml.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/mp3.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/pdf.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/pdf.png +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/text.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/text.png +0 -0
- data/test/{rails_root → rails_test}/public/images/file_icons/word.gif +0 -0
- data/test/rails_test/public/images/rails.png +0 -0
- data/test/{rails_root/public/images → rails_test/public/images/swfupload}/SWFUploadButton.png +0 -0
- data/test/{rails_root/public/images → rails_test/public/images/swfupload}/cancelbutton.gif +0 -0
- data/test/{rails_root → rails_test}/public/images/uploadify/cancel.png +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/application.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/controls.js +75 -73
- data/test/{rails_root → rails_test}/public/javascripts/dragdrop.js +171 -169
- data/test/{rails_root → rails_test}/public/javascripts/effects.js +180 -177
- data/test/{rails_root/public/javascripts/jquery/jquery.js → rails_test/public/javascripts/jquery/jquery-1.4.2.min.js} +0 -0
- data/test/{rails_root/public/javascripts/jquery/jquery-ui.js → rails_test/public/javascripts/jquery/jquery-ui-1.8.4.custom.min.js} +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/jquery/jquery.uploadify.min.js +0 -0
- data/test/rails_test/public/javascripts/prototype.js +6001 -0
- data/test/rails_test/public/javascripts/rails.js +175 -0
- data/test/{rails_root → rails_test}/public/javascripts/swf/swfobject.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/fileprogress.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/handlers.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.cookies.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.proxy.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.queue.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.speed.js +0 -0
- data/test/{rails_root → rails_test}/public/javascripts/swfupload/swfupload.swfobject.js +0 -0
- data/test/rails_test/public/robots.txt +5 -0
- data/test/{rails_root/test/functional/.keep → rails_test/public/stylesheets/.gitkeep} +0 -0
- data/test/{rails_root → rails_test}/public/stylesheets/swfupload.css +0 -0
- data/test/{rails_root → rails_test}/public/stylesheets/uploadify.css +0 -0
- data/test/{rails_root → rails_test}/public/swf/expressInstall.swf +0 -0
- data/test/{rails_root → rails_test}/public/swf/swfupload.swf +0 -0
- data/test/{rails_root → rails_test}/public/swf/swfupload_fp9.swf +0 -0
- data/test/{rails_root → rails_test}/public/swf/uploadify.swf +0 -0
- data/test/rails_test/script/rails +6 -0
- data/test/{rails_root → rails_test}/test/factories.rb +1 -1
- data/test/{rails_root → rails_test}/test/fixtures/files/5k.png +0 -0
- data/test/{rails_root → rails_test}/test/fixtures/files/IT'sUPPERCASE!AND WeIRD.JPG +0 -0
- data/test/rails_test/test/fixtures/rails.png +0 -0
- data/test/{rails_root/test → rails_test/test/fixtures}/test.doc +0 -0
- data/test/{rails_root/test → rails_test/test/fixtures}/test.pdf +0 -0
- data/test/rails_test/test/fixtures/test.txt +1 -0
- data/test/{rails_root/test → rails_test/test/fixtures}/test.xls +0 -0
- data/test/{rails_root/test/integration → rails_test/test/functional}/.keep +0 -0
- data/test/{rails_root → rails_test}/test/functional/default_controller_test.rb +0 -0
- data/test/{rails_root → rails_test}/test/functional/uploads_controller_test.rb +0 -0
- data/test/{rails_root/test/mocks/development → rails_test/test/integration}/.keep +0 -0
- data/test/rails_test/test/performance/browsing_test.rb +9 -0
- data/test/{rails_root → rails_test}/test/shoulda_macros/paperclip.rb +0 -0
- data/test/rails_test/test/test_helper.rb +25 -0
- data/test/{rails_root/test/mocks/test → rails_test/test/unit}/.keep +0 -0
- data/test/{rails_root → rails_test}/test/unit/upload_test.rb +9 -18
- data/test/{rails_root/test/unit/.keep → rails_test/vendor/plugins/.gitkeep} +0 -0
- data/uploader.gemspec +225 -255
- metadata +228 -258
- data/Gemfile +0 -13
- data/config/uploader_routes.rb +0 -3
- data/lib/active_record/acts/uploader_upload.rb +0 -279
- data/lib/uploader/initialize_routes.rb +0 -8
- data/lib/uploader/tasks.rb +0 -42
- data/rails/init.rb +0 -38
- data/tasks/rails.rake +0 -2
- data/test/rails_root/Capfile +0 -3
- data/test/rails_root/app/controllers/default_controller.rb +0 -12
- data/test/rails_root/app/models/upload.rb +0 -55
- data/test/rails_root/app/views/default/uploadify.html.erb +0 -17
- data/test/rails_root/config/boot.rb +0 -109
- data/test/rails_root/config/environment.rb +0 -29
- data/test/rails_root/config/environments/development.rb +0 -19
- data/test/rails_root/config/environments/production.rb +0 -1
- data/test/rails_root/config/environments/test.rb +0 -27
- data/test/rails_root/config/initializers/requires.rb +0 -13
- data/test/rails_root/config/initializers/session_store.rb +0 -8
- data/test/rails_root/config/initializers/uploader.rb +0 -11
- data/test/rails_root/config/routes.rb +0 -13
- data/test/rails_root/db/development.sqlite3 +0 -0
- data/test/rails_root/db/schema.rb +0 -47
- data/test/rails_root/db/test.sqlite3 +0 -0
- data/test/rails_root/public/.htaccess +0 -40
- data/test/rails_root/public/404.html +0 -30
- data/test/rails_root/public/422.html +0 -30
- data/test/rails_root/public/500.html +0 -30
- data/test/rails_root/public/dispatch.rb +0 -10
- data/test/rails_root/public/images/rails.png +0 -0
- data/test/rails_root/public/images/swfupload/SWFUploadButton.png +0 -0
- data/test/rails_root/public/images/swfupload/cancelbutton.gif +0 -0
- data/test/rails_root/public/javascripts/builder.js +0 -136
- data/test/rails_root/public/javascripts/jquery/jquery.easing.js +0 -1
- data/test/rails_root/public/javascripts/jquery/jquery.fancybox.js +0 -9
- data/test/rails_root/public/javascripts/jquery/jquery.form.js +0 -637
- data/test/rails_root/public/javascripts/jquery/jquery.jgrowl.js +0 -2
- data/test/rails_root/public/javascripts/jquery/jquery.tips.js +0 -69
- data/test/rails_root/public/javascripts/jquery/jrails.js +0 -1
- data/test/rails_root/public/javascripts/prototype.js +0 -4225
- data/test/rails_root/public/javascripts/scriptaculous.js +0 -58
- data/test/rails_root/public/javascripts/slider.js +0 -277
- data/test/rails_root/public/javascripts/sound.js +0 -60
- data/test/rails_root/public/robots.txt +0 -1
- data/test/rails_root/script/about +0 -3
- data/test/rails_root/script/breakpointer +0 -3
- data/test/rails_root/script/console +0 -3
- data/test/rails_root/script/create_project.rb +0 -52
- data/test/rails_root/script/cucumber +0 -7
- data/test/rails_root/script/dbconsole +0 -3
- data/test/rails_root/script/destroy +0 -3
- data/test/rails_root/script/generate +0 -3
- data/test/rails_root/script/performance/benchmarker +0 -3
- data/test/rails_root/script/performance/profiler +0 -3
- data/test/rails_root/script/performance/request +0 -3
- data/test/rails_root/script/plugin +0 -3
- data/test/rails_root/script/process/inspector +0 -3
- data/test/rails_root/script/process/reaper +0 -3
- data/test/rails_root/script/process/spawner +0 -3
- data/test/rails_root/script/runner +0 -3
- data/test/rails_root/script/server +0 -3
- data/test/rails_root/test/test_helper.rb +0 -26
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
//
|
|
1
|
+
// script.aculo.us dragdrop.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
|
|
2
|
+
|
|
3
|
+
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
|
4
|
+
//
|
|
4
5
|
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
|
5
6
|
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
|
6
7
|
|
|
@@ -32,7 +33,7 @@ var Droppables = {
|
|
|
32
33
|
options._containers.push($(containment));
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
|
|
36
37
|
if(options.accept) options.accept = [options.accept].flatten();
|
|
37
38
|
|
|
38
39
|
Element.makePositioned(element); // fix IE
|
|
@@ -40,34 +41,34 @@ var Droppables = {
|
|
|
40
41
|
|
|
41
42
|
this.drops.push(options);
|
|
42
43
|
},
|
|
43
|
-
|
|
44
|
+
|
|
44
45
|
findDeepestChild: function(drops) {
|
|
45
46
|
deepest = drops[0];
|
|
46
|
-
|
|
47
|
+
|
|
47
48
|
for (i = 1; i < drops.length; ++i)
|
|
48
49
|
if (Element.isParent(drops[i].element, deepest.element))
|
|
49
50
|
deepest = drops[i];
|
|
50
|
-
|
|
51
|
+
|
|
51
52
|
return deepest;
|
|
52
53
|
},
|
|
53
54
|
|
|
54
55
|
isContained: function(element, drop) {
|
|
55
56
|
var containmentNode;
|
|
56
57
|
if(drop.tree) {
|
|
57
|
-
containmentNode = element.treeNode;
|
|
58
|
+
containmentNode = element.treeNode;
|
|
58
59
|
} else {
|
|
59
60
|
containmentNode = element.parentNode;
|
|
60
61
|
}
|
|
61
62
|
return drop._containers.detect(function(c) { return containmentNode == c });
|
|
62
63
|
},
|
|
63
|
-
|
|
64
|
+
|
|
64
65
|
isAffected: function(point, element, drop) {
|
|
65
66
|
return (
|
|
66
67
|
(drop.element!=element) &&
|
|
67
68
|
((!drop._containers) ||
|
|
68
69
|
this.isContained(element, drop)) &&
|
|
69
70
|
((!drop.accept) ||
|
|
70
|
-
(Element.classNames(element).detect(
|
|
71
|
+
(Element.classNames(element).detect(
|
|
71
72
|
function(v) { return drop.accept.include(v) } ) )) &&
|
|
72
73
|
Position.within(drop.element, point[0], point[1]) );
|
|
73
74
|
},
|
|
@@ -87,12 +88,12 @@ var Droppables = {
|
|
|
87
88
|
show: function(point, element) {
|
|
88
89
|
if(!this.drops.length) return;
|
|
89
90
|
var drop, affected = [];
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
this.drops.each( function(drop) {
|
|
92
93
|
if(Droppables.isAffected(point, element, drop))
|
|
93
94
|
affected.push(drop);
|
|
94
95
|
});
|
|
95
|
-
|
|
96
|
+
|
|
96
97
|
if(affected.length>0)
|
|
97
98
|
drop = Droppables.findDeepestChild(affected);
|
|
98
99
|
|
|
@@ -101,7 +102,7 @@ var Droppables = {
|
|
|
101
102
|
Position.within(drop.element, point[0], point[1]);
|
|
102
103
|
if(drop.onHover)
|
|
103
104
|
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
|
|
104
|
-
|
|
105
|
+
|
|
105
106
|
if (drop != this.last_active) Droppables.activate(drop);
|
|
106
107
|
}
|
|
107
108
|
},
|
|
@@ -112,8 +113,8 @@ var Droppables = {
|
|
|
112
113
|
|
|
113
114
|
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
|
|
114
115
|
if (this.last_active.onDrop) {
|
|
115
|
-
this.last_active.onDrop(element, this.last_active.element, event);
|
|
116
|
-
return true;
|
|
116
|
+
this.last_active.onDrop(element, this.last_active.element, event);
|
|
117
|
+
return true;
|
|
117
118
|
}
|
|
118
119
|
},
|
|
119
120
|
|
|
@@ -121,25 +122,25 @@ var Droppables = {
|
|
|
121
122
|
if(this.last_active)
|
|
122
123
|
this.deactivate(this.last_active);
|
|
123
124
|
}
|
|
124
|
-
}
|
|
125
|
+
};
|
|
125
126
|
|
|
126
127
|
var Draggables = {
|
|
127
128
|
drags: [],
|
|
128
129
|
observers: [],
|
|
129
|
-
|
|
130
|
+
|
|
130
131
|
register: function(draggable) {
|
|
131
132
|
if(this.drags.length == 0) {
|
|
132
133
|
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
|
|
133
134
|
this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
|
|
134
135
|
this.eventKeypress = this.keyPress.bindAsEventListener(this);
|
|
135
|
-
|
|
136
|
+
|
|
136
137
|
Event.observe(document, "mouseup", this.eventMouseUp);
|
|
137
138
|
Event.observe(document, "mousemove", this.eventMouseMove);
|
|
138
139
|
Event.observe(document, "keypress", this.eventKeypress);
|
|
139
140
|
}
|
|
140
141
|
this.drags.push(draggable);
|
|
141
142
|
},
|
|
142
|
-
|
|
143
|
+
|
|
143
144
|
unregister: function(draggable) {
|
|
144
145
|
this.drags = this.drags.reject(function(d) { return d==draggable });
|
|
145
146
|
if(this.drags.length == 0) {
|
|
@@ -148,24 +149,24 @@ var Draggables = {
|
|
|
148
149
|
Event.stopObserving(document, "keypress", this.eventKeypress);
|
|
149
150
|
}
|
|
150
151
|
},
|
|
151
|
-
|
|
152
|
+
|
|
152
153
|
activate: function(draggable) {
|
|
153
|
-
if(draggable.options.delay) {
|
|
154
|
-
this._timeout = setTimeout(function() {
|
|
155
|
-
Draggables._timeout = null;
|
|
156
|
-
window.focus();
|
|
157
|
-
Draggables.activeDraggable = draggable;
|
|
158
|
-
}.bind(this), draggable.options.delay);
|
|
154
|
+
if(draggable.options.delay) {
|
|
155
|
+
this._timeout = setTimeout(function() {
|
|
156
|
+
Draggables._timeout = null;
|
|
157
|
+
window.focus();
|
|
158
|
+
Draggables.activeDraggable = draggable;
|
|
159
|
+
}.bind(this), draggable.options.delay);
|
|
159
160
|
} else {
|
|
160
161
|
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
|
|
161
162
|
this.activeDraggable = draggable;
|
|
162
163
|
}
|
|
163
164
|
},
|
|
164
|
-
|
|
165
|
+
|
|
165
166
|
deactivate: function() {
|
|
166
167
|
this.activeDraggable = null;
|
|
167
168
|
},
|
|
168
|
-
|
|
169
|
+
|
|
169
170
|
updateDrag: function(event) {
|
|
170
171
|
if(!this.activeDraggable) return;
|
|
171
172
|
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
|
@@ -173,36 +174,36 @@ var Draggables = {
|
|
|
173
174
|
// the same coordinates, prevent needless redrawing (moz bug?)
|
|
174
175
|
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
|
|
175
176
|
this._lastPointer = pointer;
|
|
176
|
-
|
|
177
|
+
|
|
177
178
|
this.activeDraggable.updateDrag(event, pointer);
|
|
178
179
|
},
|
|
179
|
-
|
|
180
|
+
|
|
180
181
|
endDrag: function(event) {
|
|
181
|
-
if(this._timeout) {
|
|
182
|
-
clearTimeout(this._timeout);
|
|
183
|
-
this._timeout = null;
|
|
182
|
+
if(this._timeout) {
|
|
183
|
+
clearTimeout(this._timeout);
|
|
184
|
+
this._timeout = null;
|
|
184
185
|
}
|
|
185
186
|
if(!this.activeDraggable) return;
|
|
186
187
|
this._lastPointer = null;
|
|
187
188
|
this.activeDraggable.endDrag(event);
|
|
188
189
|
this.activeDraggable = null;
|
|
189
190
|
},
|
|
190
|
-
|
|
191
|
+
|
|
191
192
|
keyPress: function(event) {
|
|
192
193
|
if(this.activeDraggable)
|
|
193
194
|
this.activeDraggable.keyPress(event);
|
|
194
195
|
},
|
|
195
|
-
|
|
196
|
+
|
|
196
197
|
addObserver: function(observer) {
|
|
197
198
|
this.observers.push(observer);
|
|
198
199
|
this._cacheObserverCallbacks();
|
|
199
200
|
},
|
|
200
|
-
|
|
201
|
+
|
|
201
202
|
removeObserver: function(element) { // element instead of observer fixes mem leaks
|
|
202
203
|
this.observers = this.observers.reject( function(o) { return o.element==element });
|
|
203
204
|
this._cacheObserverCallbacks();
|
|
204
205
|
},
|
|
205
|
-
|
|
206
|
+
|
|
206
207
|
notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
|
|
207
208
|
if(this[eventName+'Count'] > 0)
|
|
208
209
|
this.observers.each( function(o) {
|
|
@@ -210,7 +211,7 @@ var Draggables = {
|
|
|
210
211
|
});
|
|
211
212
|
if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
|
|
212
213
|
},
|
|
213
|
-
|
|
214
|
+
|
|
214
215
|
_cacheObserverCallbacks: function() {
|
|
215
216
|
['onStart','onEnd','onDrag'].each( function(eventName) {
|
|
216
217
|
Draggables[eventName+'Count'] = Draggables.observers.select(
|
|
@@ -218,7 +219,7 @@ var Draggables = {
|
|
|
218
219
|
).length;
|
|
219
220
|
});
|
|
220
221
|
}
|
|
221
|
-
}
|
|
222
|
+
};
|
|
222
223
|
|
|
223
224
|
/*--------------------------------------------------------------------------*/
|
|
224
225
|
|
|
@@ -234,12 +235,12 @@ var Draggable = Class.create({
|
|
|
234
235
|
},
|
|
235
236
|
endeffect: function(element) {
|
|
236
237
|
var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
|
|
237
|
-
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
|
|
238
|
+
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
|
|
238
239
|
queue: {scope:'_draggable', position:'end'},
|
|
239
|
-
afterFinish: function(){
|
|
240
|
-
Draggable._dragging[element] = false
|
|
240
|
+
afterFinish: function(){
|
|
241
|
+
Draggable._dragging[element] = false
|
|
241
242
|
}
|
|
242
|
-
});
|
|
243
|
+
});
|
|
243
244
|
},
|
|
244
245
|
zindex: 1000,
|
|
245
246
|
revert: false,
|
|
@@ -250,57 +251,57 @@ var Draggable = Class.create({
|
|
|
250
251
|
snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
|
|
251
252
|
delay: 0
|
|
252
253
|
};
|
|
253
|
-
|
|
254
|
+
|
|
254
255
|
if(!arguments[1] || Object.isUndefined(arguments[1].endeffect))
|
|
255
256
|
Object.extend(defaults, {
|
|
256
257
|
starteffect: function(element) {
|
|
257
258
|
element._opacity = Element.getOpacity(element);
|
|
258
259
|
Draggable._dragging[element] = true;
|
|
259
|
-
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
|
|
260
|
+
new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
|
|
260
261
|
}
|
|
261
262
|
});
|
|
262
|
-
|
|
263
|
+
|
|
263
264
|
var options = Object.extend(defaults, arguments[1] || { });
|
|
264
265
|
|
|
265
266
|
this.element = $(element);
|
|
266
|
-
|
|
267
|
+
|
|
267
268
|
if(options.handle && Object.isString(options.handle))
|
|
268
269
|
this.handle = this.element.down('.'+options.handle, 0);
|
|
269
|
-
|
|
270
|
+
|
|
270
271
|
if(!this.handle) this.handle = $(options.handle);
|
|
271
272
|
if(!this.handle) this.handle = this.element;
|
|
272
|
-
|
|
273
|
+
|
|
273
274
|
if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
|
|
274
275
|
options.scroll = $(options.scroll);
|
|
275
276
|
this._isScrollChild = Element.childOf(this.element, options.scroll);
|
|
276
277
|
}
|
|
277
278
|
|
|
278
|
-
Element.makePositioned(this.element); // fix IE
|
|
279
|
+
Element.makePositioned(this.element); // fix IE
|
|
279
280
|
|
|
280
281
|
this.options = options;
|
|
281
|
-
this.dragging = false;
|
|
282
|
+
this.dragging = false;
|
|
282
283
|
|
|
283
284
|
this.eventMouseDown = this.initDrag.bindAsEventListener(this);
|
|
284
285
|
Event.observe(this.handle, "mousedown", this.eventMouseDown);
|
|
285
|
-
|
|
286
|
+
|
|
286
287
|
Draggables.register(this);
|
|
287
288
|
},
|
|
288
|
-
|
|
289
|
+
|
|
289
290
|
destroy: function() {
|
|
290
291
|
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
|
|
291
292
|
Draggables.unregister(this);
|
|
292
293
|
},
|
|
293
|
-
|
|
294
|
+
|
|
294
295
|
currentDelta: function() {
|
|
295
296
|
return([
|
|
296
297
|
parseInt(Element.getStyle(this.element,'left') || '0'),
|
|
297
298
|
parseInt(Element.getStyle(this.element,'top') || '0')]);
|
|
298
299
|
},
|
|
299
|
-
|
|
300
|
+
|
|
300
301
|
initDrag: function(event) {
|
|
301
302
|
if(!Object.isUndefined(Draggable._dragging[this.element]) &&
|
|
302
303
|
Draggable._dragging[this.element]) return;
|
|
303
|
-
if(Event.isLeftClick(event)) {
|
|
304
|
+
if(Event.isLeftClick(event)) {
|
|
304
305
|
// abort on form elements, fixes a Firefox issue
|
|
305
306
|
var src = Event.element(event);
|
|
306
307
|
if((tag_name = src.tagName.toUpperCase()) && (
|
|
@@ -309,34 +310,34 @@ var Draggable = Class.create({
|
|
|
309
310
|
tag_name=='OPTION' ||
|
|
310
311
|
tag_name=='BUTTON' ||
|
|
311
312
|
tag_name=='TEXTAREA')) return;
|
|
312
|
-
|
|
313
|
+
|
|
313
314
|
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
|
314
|
-
var pos =
|
|
315
|
+
var pos = this.element.cumulativeOffset();
|
|
315
316
|
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
|
|
316
|
-
|
|
317
|
+
|
|
317
318
|
Draggables.activate(this);
|
|
318
319
|
Event.stop(event);
|
|
319
320
|
}
|
|
320
321
|
},
|
|
321
|
-
|
|
322
|
+
|
|
322
323
|
startDrag: function(event) {
|
|
323
324
|
this.dragging = true;
|
|
324
325
|
if(!this.delta)
|
|
325
326
|
this.delta = this.currentDelta();
|
|
326
|
-
|
|
327
|
+
|
|
327
328
|
if(this.options.zindex) {
|
|
328
329
|
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
|
|
329
330
|
this.element.style.zIndex = this.options.zindex;
|
|
330
331
|
}
|
|
331
|
-
|
|
332
|
+
|
|
332
333
|
if(this.options.ghosting) {
|
|
333
334
|
this._clone = this.element.cloneNode(true);
|
|
334
|
-
this.
|
|
335
|
-
if (!this.
|
|
335
|
+
this._originallyAbsolute = (this.element.getStyle('position') == 'absolute');
|
|
336
|
+
if (!this._originallyAbsolute)
|
|
336
337
|
Position.absolutize(this.element);
|
|
337
338
|
this.element.parentNode.insertBefore(this._clone, this.element);
|
|
338
339
|
}
|
|
339
|
-
|
|
340
|
+
|
|
340
341
|
if(this.options.scroll) {
|
|
341
342
|
if (this.options.scroll == window) {
|
|
342
343
|
var where = this._getWindowScroll(this.options.scroll);
|
|
@@ -347,28 +348,28 @@ var Draggable = Class.create({
|
|
|
347
348
|
this.originalScrollTop = this.options.scroll.scrollTop;
|
|
348
349
|
}
|
|
349
350
|
}
|
|
350
|
-
|
|
351
|
+
|
|
351
352
|
Draggables.notify('onStart', this, event);
|
|
352
|
-
|
|
353
|
+
|
|
353
354
|
if(this.options.starteffect) this.options.starteffect(this.element);
|
|
354
355
|
},
|
|
355
|
-
|
|
356
|
+
|
|
356
357
|
updateDrag: function(event, pointer) {
|
|
357
358
|
if(!this.dragging) this.startDrag(event);
|
|
358
|
-
|
|
359
|
+
|
|
359
360
|
if(!this.options.quiet){
|
|
360
361
|
Position.prepare();
|
|
361
362
|
Droppables.show(pointer, this.element);
|
|
362
363
|
}
|
|
363
|
-
|
|
364
|
+
|
|
364
365
|
Draggables.notify('onDrag', this, event);
|
|
365
|
-
|
|
366
|
+
|
|
366
367
|
this.draw(pointer);
|
|
367
368
|
if(this.options.change) this.options.change(this);
|
|
368
|
-
|
|
369
|
+
|
|
369
370
|
if(this.options.scroll) {
|
|
370
371
|
this.stopScrolling();
|
|
371
|
-
|
|
372
|
+
|
|
372
373
|
var p;
|
|
373
374
|
if (this.options.scroll == window) {
|
|
374
375
|
with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; }
|
|
@@ -386,16 +387,16 @@ var Draggable = Class.create({
|
|
|
386
387
|
if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity);
|
|
387
388
|
this.startScrolling(speed);
|
|
388
389
|
}
|
|
389
|
-
|
|
390
|
+
|
|
390
391
|
// fix AppleWebKit rendering
|
|
391
392
|
if(Prototype.Browser.WebKit) window.scrollBy(0,0);
|
|
392
|
-
|
|
393
|
+
|
|
393
394
|
Event.stop(event);
|
|
394
395
|
},
|
|
395
|
-
|
|
396
|
+
|
|
396
397
|
finishDrag: function(event, success) {
|
|
397
398
|
this.dragging = false;
|
|
398
|
-
|
|
399
|
+
|
|
399
400
|
if(this.options.quiet){
|
|
400
401
|
Position.prepare();
|
|
401
402
|
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
|
@@ -403,24 +404,24 @@ var Draggable = Class.create({
|
|
|
403
404
|
}
|
|
404
405
|
|
|
405
406
|
if(this.options.ghosting) {
|
|
406
|
-
if (!this.
|
|
407
|
+
if (!this._originallyAbsolute)
|
|
407
408
|
Position.relativize(this.element);
|
|
408
|
-
delete this.
|
|
409
|
+
delete this._originallyAbsolute;
|
|
409
410
|
Element.remove(this._clone);
|
|
410
411
|
this._clone = null;
|
|
411
412
|
}
|
|
412
413
|
|
|
413
|
-
var dropped = false;
|
|
414
|
-
if(success) {
|
|
415
|
-
dropped = Droppables.fire(event, this.element);
|
|
416
|
-
if (!dropped) dropped = false;
|
|
414
|
+
var dropped = false;
|
|
415
|
+
if(success) {
|
|
416
|
+
dropped = Droppables.fire(event, this.element);
|
|
417
|
+
if (!dropped) dropped = false;
|
|
417
418
|
}
|
|
418
419
|
if(dropped && this.options.onDropped) this.options.onDropped(this.element);
|
|
419
420
|
Draggables.notify('onEnd', this, event);
|
|
420
421
|
|
|
421
422
|
var revert = this.options.revert;
|
|
422
423
|
if(revert && Object.isFunction(revert)) revert = revert(this.element);
|
|
423
|
-
|
|
424
|
+
|
|
424
425
|
var d = this.currentDelta();
|
|
425
426
|
if(revert && this.options.reverteffect) {
|
|
426
427
|
if (dropped == 0 || revert != 'failure')
|
|
@@ -433,67 +434,67 @@ var Draggable = Class.create({
|
|
|
433
434
|
if(this.options.zindex)
|
|
434
435
|
this.element.style.zIndex = this.originalZ;
|
|
435
436
|
|
|
436
|
-
if(this.options.endeffect)
|
|
437
|
+
if(this.options.endeffect)
|
|
437
438
|
this.options.endeffect(this.element);
|
|
438
|
-
|
|
439
|
+
|
|
439
440
|
Draggables.deactivate(this);
|
|
440
441
|
Droppables.reset();
|
|
441
442
|
},
|
|
442
|
-
|
|
443
|
+
|
|
443
444
|
keyPress: function(event) {
|
|
444
445
|
if(event.keyCode!=Event.KEY_ESC) return;
|
|
445
446
|
this.finishDrag(event, false);
|
|
446
447
|
Event.stop(event);
|
|
447
448
|
},
|
|
448
|
-
|
|
449
|
+
|
|
449
450
|
endDrag: function(event) {
|
|
450
451
|
if(!this.dragging) return;
|
|
451
452
|
this.stopScrolling();
|
|
452
453
|
this.finishDrag(event, true);
|
|
453
454
|
Event.stop(event);
|
|
454
455
|
},
|
|
455
|
-
|
|
456
|
+
|
|
456
457
|
draw: function(point) {
|
|
457
|
-
var pos =
|
|
458
|
+
var pos = this.element.cumulativeOffset();
|
|
458
459
|
if(this.options.ghosting) {
|
|
459
460
|
var r = Position.realOffset(this.element);
|
|
460
461
|
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
|
|
461
462
|
}
|
|
462
|
-
|
|
463
|
+
|
|
463
464
|
var d = this.currentDelta();
|
|
464
465
|
pos[0] -= d[0]; pos[1] -= d[1];
|
|
465
|
-
|
|
466
|
+
|
|
466
467
|
if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
|
|
467
468
|
pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
|
|
468
469
|
pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
|
|
469
470
|
}
|
|
470
|
-
|
|
471
|
-
var p = [0,1].map(function(i){
|
|
472
|
-
return (point[i]-pos[i]-this.offset[i])
|
|
471
|
+
|
|
472
|
+
var p = [0,1].map(function(i){
|
|
473
|
+
return (point[i]-pos[i]-this.offset[i])
|
|
473
474
|
}.bind(this));
|
|
474
|
-
|
|
475
|
+
|
|
475
476
|
if(this.options.snap) {
|
|
476
477
|
if(Object.isFunction(this.options.snap)) {
|
|
477
478
|
p = this.options.snap(p[0],p[1],this);
|
|
478
479
|
} else {
|
|
479
480
|
if(Object.isArray(this.options.snap)) {
|
|
480
481
|
p = p.map( function(v, i) {
|
|
481
|
-
return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this))
|
|
482
|
+
return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this));
|
|
482
483
|
} else {
|
|
483
484
|
p = p.map( function(v) {
|
|
484
|
-
return (v/this.options.snap).round()*this.options.snap }.bind(this))
|
|
485
|
+
return (v/this.options.snap).round()*this.options.snap }.bind(this));
|
|
485
486
|
}
|
|
486
487
|
}}
|
|
487
|
-
|
|
488
|
+
|
|
488
489
|
var style = this.element.style;
|
|
489
490
|
if((!this.options.constraint) || (this.options.constraint=='horizontal'))
|
|
490
491
|
style.left = p[0] + "px";
|
|
491
492
|
if((!this.options.constraint) || (this.options.constraint=='vertical'))
|
|
492
493
|
style.top = p[1] + "px";
|
|
493
|
-
|
|
494
|
+
|
|
494
495
|
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
|
|
495
496
|
},
|
|
496
|
-
|
|
497
|
+
|
|
497
498
|
stopScrolling: function() {
|
|
498
499
|
if(this.scrollInterval) {
|
|
499
500
|
clearInterval(this.scrollInterval);
|
|
@@ -501,14 +502,14 @@ var Draggable = Class.create({
|
|
|
501
502
|
Draggables._lastScrollPointer = null;
|
|
502
503
|
}
|
|
503
504
|
},
|
|
504
|
-
|
|
505
|
+
|
|
505
506
|
startScrolling: function(speed) {
|
|
506
507
|
if(!(speed[0] || speed[1])) return;
|
|
507
508
|
this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];
|
|
508
509
|
this.lastScrolled = new Date();
|
|
509
510
|
this.scrollInterval = setInterval(this.scroll.bind(this), 10);
|
|
510
511
|
},
|
|
511
|
-
|
|
512
|
+
|
|
512
513
|
scroll: function() {
|
|
513
514
|
var current = new Date();
|
|
514
515
|
var delta = current - this.lastScrolled;
|
|
@@ -524,7 +525,7 @@ var Draggable = Class.create({
|
|
|
524
525
|
this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
|
|
525
526
|
this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
|
|
526
527
|
}
|
|
527
|
-
|
|
528
|
+
|
|
528
529
|
Position.prepare();
|
|
529
530
|
Droppables.show(Draggables._lastPointer, this.element);
|
|
530
531
|
Draggables.notify('onDrag', this);
|
|
@@ -538,10 +539,10 @@ var Draggable = Class.create({
|
|
|
538
539
|
Draggables._lastScrollPointer[1] = 0;
|
|
539
540
|
this.draw(Draggables._lastScrollPointer);
|
|
540
541
|
}
|
|
541
|
-
|
|
542
|
+
|
|
542
543
|
if(this.options.change) this.options.change(this);
|
|
543
544
|
},
|
|
544
|
-
|
|
545
|
+
|
|
545
546
|
_getWindowScroll: function(w) {
|
|
546
547
|
var T, L, W, H;
|
|
547
548
|
with (w.document) {
|
|
@@ -560,7 +561,7 @@ var Draggable = Class.create({
|
|
|
560
561
|
H = documentElement.clientHeight;
|
|
561
562
|
} else {
|
|
562
563
|
W = body.offsetWidth;
|
|
563
|
-
H = body.offsetHeight
|
|
564
|
+
H = body.offsetHeight;
|
|
564
565
|
}
|
|
565
566
|
}
|
|
566
567
|
return { top: T, left: L, width: W, height: H };
|
|
@@ -577,11 +578,11 @@ var SortableObserver = Class.create({
|
|
|
577
578
|
this.observer = observer;
|
|
578
579
|
this.lastValue = Sortable.serialize(this.element);
|
|
579
580
|
},
|
|
580
|
-
|
|
581
|
+
|
|
581
582
|
onStart: function() {
|
|
582
583
|
this.lastValue = Sortable.serialize(this.element);
|
|
583
584
|
},
|
|
584
|
-
|
|
585
|
+
|
|
585
586
|
onEnd: function() {
|
|
586
587
|
Sortable.unmark();
|
|
587
588
|
if(this.lastValue != Sortable.serialize(this.element))
|
|
@@ -591,11 +592,11 @@ var SortableObserver = Class.create({
|
|
|
591
592
|
|
|
592
593
|
var Sortable = {
|
|
593
594
|
SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,
|
|
594
|
-
|
|
595
|
+
|
|
595
596
|
sortables: { },
|
|
596
|
-
|
|
597
|
+
|
|
597
598
|
_findRootElement: function(element) {
|
|
598
|
-
while (element.tagName.toUpperCase() != "BODY") {
|
|
599
|
+
while (element.tagName.toUpperCase() != "BODY") {
|
|
599
600
|
if(element.id && Sortable.sortables[element.id]) return element;
|
|
600
601
|
element = element.parentNode;
|
|
601
602
|
}
|
|
@@ -606,22 +607,23 @@ var Sortable = {
|
|
|
606
607
|
if(!element) return;
|
|
607
608
|
return Sortable.sortables[element.id];
|
|
608
609
|
},
|
|
609
|
-
|
|
610
|
+
|
|
610
611
|
destroy: function(element){
|
|
611
|
-
|
|
612
|
-
|
|
612
|
+
element = $(element);
|
|
613
|
+
var s = Sortable.sortables[element.id];
|
|
614
|
+
|
|
613
615
|
if(s) {
|
|
614
616
|
Draggables.removeObserver(s.element);
|
|
615
617
|
s.droppables.each(function(d){ Droppables.remove(d) });
|
|
616
618
|
s.draggables.invoke('destroy');
|
|
617
|
-
|
|
619
|
+
|
|
618
620
|
delete Sortable.sortables[s.element.id];
|
|
619
621
|
}
|
|
620
622
|
},
|
|
621
623
|
|
|
622
624
|
create: function(element) {
|
|
623
625
|
element = $(element);
|
|
624
|
-
var options = Object.extend({
|
|
626
|
+
var options = Object.extend({
|
|
625
627
|
element: element,
|
|
626
628
|
tag: 'li', // assumes li children, override with tag: 'tagname'
|
|
627
629
|
dropOnEmpty: false,
|
|
@@ -635,17 +637,17 @@ var Sortable = {
|
|
|
635
637
|
delay: 0,
|
|
636
638
|
hoverclass: null,
|
|
637
639
|
ghosting: false,
|
|
638
|
-
quiet: false,
|
|
640
|
+
quiet: false,
|
|
639
641
|
scroll: false,
|
|
640
642
|
scrollSensitivity: 20,
|
|
641
643
|
scrollSpeed: 15,
|
|
642
644
|
format: this.SERIALIZE_RULE,
|
|
643
|
-
|
|
644
|
-
// these take arrays of elements or ids and can be
|
|
645
|
+
|
|
646
|
+
// these take arrays of elements or ids and can be
|
|
645
647
|
// used for better initialization performance
|
|
646
648
|
elements: false,
|
|
647
649
|
handles: false,
|
|
648
|
-
|
|
650
|
+
|
|
649
651
|
onChange: Prototype.emptyFunction,
|
|
650
652
|
onUpdate: Prototype.emptyFunction
|
|
651
653
|
}, arguments[1] || { });
|
|
@@ -682,24 +684,24 @@ var Sortable = {
|
|
|
682
684
|
if(options.zindex)
|
|
683
685
|
options_for_draggable.zindex = options.zindex;
|
|
684
686
|
|
|
685
|
-
// build options for the droppables
|
|
687
|
+
// build options for the droppables
|
|
686
688
|
var options_for_droppable = {
|
|
687
689
|
overlap: options.overlap,
|
|
688
690
|
containment: options.containment,
|
|
689
691
|
tree: options.tree,
|
|
690
692
|
hoverclass: options.hoverclass,
|
|
691
693
|
onHover: Sortable.onHover
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
+
};
|
|
695
|
+
|
|
694
696
|
var options_for_tree = {
|
|
695
697
|
onHover: Sortable.onEmptyHover,
|
|
696
698
|
overlap: options.overlap,
|
|
697
699
|
containment: options.containment,
|
|
698
700
|
hoverclass: options.hoverclass
|
|
699
|
-
}
|
|
701
|
+
};
|
|
700
702
|
|
|
701
703
|
// fix for gecko engine
|
|
702
|
-
Element.cleanWhitespace(element);
|
|
704
|
+
Element.cleanWhitespace(element);
|
|
703
705
|
|
|
704
706
|
options.draggables = [];
|
|
705
707
|
options.droppables = [];
|
|
@@ -712,14 +714,14 @@ var Sortable = {
|
|
|
712
714
|
|
|
713
715
|
(options.elements || this.findElements(element, options) || []).each( function(e,i) {
|
|
714
716
|
var handle = options.handles ? $(options.handles[i]) :
|
|
715
|
-
(options.handle ? $(e).select('.' + options.handle)[0] : e);
|
|
717
|
+
(options.handle ? $(e).select('.' + options.handle)[0] : e);
|
|
716
718
|
options.draggables.push(
|
|
717
719
|
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
|
|
718
720
|
Droppables.add(e, options_for_droppable);
|
|
719
721
|
if(options.tree) e.treeNode = element;
|
|
720
|
-
options.droppables.push(e);
|
|
722
|
+
options.droppables.push(e);
|
|
721
723
|
});
|
|
722
|
-
|
|
724
|
+
|
|
723
725
|
if(options.tree) {
|
|
724
726
|
(Sortable.findTreeElements(element, options) || []).each( function(e) {
|
|
725
727
|
Droppables.add(e, options_for_tree);
|
|
@@ -729,7 +731,7 @@ var Sortable = {
|
|
|
729
731
|
}
|
|
730
732
|
|
|
731
733
|
// keep reference
|
|
732
|
-
this.sortables[element.
|
|
734
|
+
this.sortables[element.identify()] = options;
|
|
733
735
|
|
|
734
736
|
// for onupdate
|
|
735
737
|
Draggables.addObserver(new SortableObserver(element, options.onUpdate));
|
|
@@ -741,7 +743,7 @@ var Sortable = {
|
|
|
741
743
|
return Element.findChildren(
|
|
742
744
|
element, options.only, options.tree ? true : false, options.tag);
|
|
743
745
|
},
|
|
744
|
-
|
|
746
|
+
|
|
745
747
|
findTreeElements: function(element, options) {
|
|
746
748
|
return Element.findChildren(
|
|
747
749
|
element, options.only, options.tree ? true : false, options.treeTag);
|
|
@@ -758,7 +760,7 @@ var Sortable = {
|
|
|
758
760
|
var oldParentNode = element.parentNode;
|
|
759
761
|
element.style.visibility = "hidden"; // fix gecko rendering
|
|
760
762
|
dropon.parentNode.insertBefore(element, dropon);
|
|
761
|
-
if(dropon.parentNode!=oldParentNode)
|
|
763
|
+
if(dropon.parentNode!=oldParentNode)
|
|
762
764
|
Sortable.options(oldParentNode).onChange(element);
|
|
763
765
|
Sortable.options(dropon.parentNode).onChange(element);
|
|
764
766
|
}
|
|
@@ -769,26 +771,26 @@ var Sortable = {
|
|
|
769
771
|
var oldParentNode = element.parentNode;
|
|
770
772
|
element.style.visibility = "hidden"; // fix gecko rendering
|
|
771
773
|
dropon.parentNode.insertBefore(element, nextElement);
|
|
772
|
-
if(dropon.parentNode!=oldParentNode)
|
|
774
|
+
if(dropon.parentNode!=oldParentNode)
|
|
773
775
|
Sortable.options(oldParentNode).onChange(element);
|
|
774
776
|
Sortable.options(dropon.parentNode).onChange(element);
|
|
775
777
|
}
|
|
776
778
|
}
|
|
777
779
|
},
|
|
778
|
-
|
|
780
|
+
|
|
779
781
|
onEmptyHover: function(element, dropon, overlap) {
|
|
780
782
|
var oldParentNode = element.parentNode;
|
|
781
783
|
var droponOptions = Sortable.options(dropon);
|
|
782
|
-
|
|
784
|
+
|
|
783
785
|
if(!Element.isParent(dropon, element)) {
|
|
784
786
|
var index;
|
|
785
|
-
|
|
787
|
+
|
|
786
788
|
var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only});
|
|
787
789
|
var child = null;
|
|
788
|
-
|
|
790
|
+
|
|
789
791
|
if(children) {
|
|
790
792
|
var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
|
|
791
|
-
|
|
793
|
+
|
|
792
794
|
for (index = 0; index < children.length; index += 1) {
|
|
793
795
|
if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) {
|
|
794
796
|
offset -= Element.offsetSize (children[index], droponOptions.overlap);
|
|
@@ -801,9 +803,9 @@ var Sortable = {
|
|
|
801
803
|
}
|
|
802
804
|
}
|
|
803
805
|
}
|
|
804
|
-
|
|
806
|
+
|
|
805
807
|
dropon.insertBefore(element, child);
|
|
806
|
-
|
|
808
|
+
|
|
807
809
|
Sortable.options(oldParentNode).onChange(element);
|
|
808
810
|
droponOptions.onChange(element);
|
|
809
811
|
}
|
|
@@ -816,34 +818,34 @@ var Sortable = {
|
|
|
816
818
|
mark: function(dropon, position) {
|
|
817
819
|
// mark on ghosting only
|
|
818
820
|
var sortable = Sortable.options(dropon.parentNode);
|
|
819
|
-
if(sortable && !sortable.ghosting) return;
|
|
821
|
+
if(sortable && !sortable.ghosting) return;
|
|
820
822
|
|
|
821
823
|
if(!Sortable._marker) {
|
|
822
|
-
Sortable._marker =
|
|
824
|
+
Sortable._marker =
|
|
823
825
|
($('dropmarker') || Element.extend(document.createElement('DIV'))).
|
|
824
826
|
hide().addClassName('dropmarker').setStyle({position:'absolute'});
|
|
825
827
|
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
|
|
826
|
-
}
|
|
827
|
-
var offsets =
|
|
828
|
+
}
|
|
829
|
+
var offsets = dropon.cumulativeOffset();
|
|
828
830
|
Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
|
|
829
|
-
|
|
831
|
+
|
|
830
832
|
if(position=='after')
|
|
831
|
-
if(sortable.overlap == 'horizontal')
|
|
833
|
+
if(sortable.overlap == 'horizontal')
|
|
832
834
|
Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'});
|
|
833
835
|
else
|
|
834
836
|
Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'});
|
|
835
|
-
|
|
837
|
+
|
|
836
838
|
Sortable._marker.show();
|
|
837
839
|
},
|
|
838
|
-
|
|
840
|
+
|
|
839
841
|
_tree: function(element, options, parent) {
|
|
840
842
|
var children = Sortable.findElements(element, options) || [];
|
|
841
|
-
|
|
843
|
+
|
|
842
844
|
for (var i = 0; i < children.length; ++i) {
|
|
843
845
|
var match = children[i].id.match(options.format);
|
|
844
846
|
|
|
845
847
|
if (!match) continue;
|
|
846
|
-
|
|
848
|
+
|
|
847
849
|
var child = {
|
|
848
850
|
id: encodeURIComponent(match ? match[1] : null),
|
|
849
851
|
element: element,
|
|
@@ -851,16 +853,16 @@ var Sortable = {
|
|
|
851
853
|
children: [],
|
|
852
854
|
position: parent.children.length,
|
|
853
855
|
container: $(children[i]).down(options.treeTag)
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
+
};
|
|
857
|
+
|
|
856
858
|
/* Get the element containing the children and recurse over it */
|
|
857
859
|
if (child.container)
|
|
858
|
-
this._tree(child.container, options, child)
|
|
859
|
-
|
|
860
|
+
this._tree(child.container, options, child);
|
|
861
|
+
|
|
860
862
|
parent.children.push (child);
|
|
861
863
|
}
|
|
862
864
|
|
|
863
|
-
return parent;
|
|
865
|
+
return parent;
|
|
864
866
|
},
|
|
865
867
|
|
|
866
868
|
tree: function(element) {
|
|
@@ -873,15 +875,15 @@ var Sortable = {
|
|
|
873
875
|
name: element.id,
|
|
874
876
|
format: sortableOptions.format
|
|
875
877
|
}, arguments[1] || { });
|
|
876
|
-
|
|
878
|
+
|
|
877
879
|
var root = {
|
|
878
880
|
id: null,
|
|
879
881
|
parent: null,
|
|
880
882
|
children: [],
|
|
881
883
|
container: element,
|
|
882
884
|
position: 0
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
+
};
|
|
886
|
+
|
|
885
887
|
return Sortable._tree(element, options, root);
|
|
886
888
|
},
|
|
887
889
|
|
|
@@ -897,7 +899,7 @@ var Sortable = {
|
|
|
897
899
|
sequence: function(element) {
|
|
898
900
|
element = $(element);
|
|
899
901
|
var options = Object.extend(this.options(element), arguments[1] || { });
|
|
900
|
-
|
|
902
|
+
|
|
901
903
|
return $(this.findElements(element, options) || []).map( function(item) {
|
|
902
904
|
return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
|
|
903
905
|
});
|
|
@@ -906,14 +908,14 @@ var Sortable = {
|
|
|
906
908
|
setSequence: function(element, new_sequence) {
|
|
907
909
|
element = $(element);
|
|
908
910
|
var options = Object.extend(this.options(element), arguments[2] || { });
|
|
909
|
-
|
|
911
|
+
|
|
910
912
|
var nodeMap = { };
|
|
911
913
|
this.findElements(element, options).each( function(n) {
|
|
912
914
|
if (n.id.match(options.format))
|
|
913
915
|
nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];
|
|
914
916
|
n.parentNode.removeChild(n);
|
|
915
917
|
});
|
|
916
|
-
|
|
918
|
+
|
|
917
919
|
new_sequence.each(function(ident) {
|
|
918
920
|
var n = nodeMap[ident];
|
|
919
921
|
if (n) {
|
|
@@ -922,16 +924,16 @@ var Sortable = {
|
|
|
922
924
|
}
|
|
923
925
|
});
|
|
924
926
|
},
|
|
925
|
-
|
|
927
|
+
|
|
926
928
|
serialize: function(element) {
|
|
927
929
|
element = $(element);
|
|
928
930
|
var options = Object.extend(Sortable.options(element), arguments[1] || { });
|
|
929
931
|
var name = encodeURIComponent(
|
|
930
932
|
(arguments[1] && arguments[1].name) ? arguments[1].name : element.id);
|
|
931
|
-
|
|
933
|
+
|
|
932
934
|
if (options.tree) {
|
|
933
935
|
return Sortable.tree(element, arguments[1]).children.map( function (item) {
|
|
934
|
-
return [name + Sortable._constructIndex(item) + "[id]=" +
|
|
936
|
+
return [name + Sortable._constructIndex(item) + "[id]=" +
|
|
935
937
|
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
|
|
936
938
|
}).flatten().join('&');
|
|
937
939
|
} else {
|
|
@@ -940,16 +942,16 @@ var Sortable = {
|
|
|
940
942
|
}).join('&');
|
|
941
943
|
}
|
|
942
944
|
}
|
|
943
|
-
}
|
|
945
|
+
};
|
|
944
946
|
|
|
945
947
|
// Returns true if child is contained within element
|
|
946
948
|
Element.isParent = function(child, element) {
|
|
947
949
|
if (!child.parentNode || child == element) return false;
|
|
948
950
|
if (child.parentNode == element) return true;
|
|
949
951
|
return Element.isParent(child.parentNode, element);
|
|
950
|
-
}
|
|
952
|
+
};
|
|
951
953
|
|
|
952
|
-
Element.findChildren = function(element, only, recursive, tagName) {
|
|
954
|
+
Element.findChildren = function(element, only, recursive, tagName) {
|
|
953
955
|
if(!element.hasChildNodes()) return null;
|
|
954
956
|
tagName = tagName.toUpperCase();
|
|
955
957
|
if(only) only = [only].flatten();
|
|
@@ -965,8 +967,8 @@ Element.findChildren = function(element, only, recursive, tagName) {
|
|
|
965
967
|
});
|
|
966
968
|
|
|
967
969
|
return (elements.length>0 ? elements.flatten() : []);
|
|
968
|
-
}
|
|
970
|
+
};
|
|
969
971
|
|
|
970
972
|
Element.offsetSize = function (element, type) {
|
|
971
973
|
return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
|
|
972
|
-
}
|
|
974
|
+
};
|