rails 0.14.2 → 0.14.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails might be problematic. Click here for more details.

Files changed (53) hide show
  1. data/CHANGELOG +83 -0
  2. data/README +16 -53
  3. data/Rakefile +10 -11
  4. data/bin/about +3 -0
  5. data/bin/plugin +3 -0
  6. data/configs/database.yml +65 -3
  7. data/configs/lighttpd.conf +40 -0
  8. data/environments/boot.rb +2 -2
  9. data/environments/environment.rb +3 -3
  10. data/environments/test.rb +1 -7
  11. data/helpers/test_helper.rb +19 -4
  12. data/html/javascripts/controls.js +18 -5
  13. data/html/javascripts/dragdrop.js +6 -3
  14. data/html/javascripts/effects.js +181 -290
  15. data/html/javascripts/prototype.js +13 -11
  16. data/lib/commands/about.rb +2 -0
  17. data/lib/commands/plugin.rb +823 -0
  18. data/lib/commands/process/reaper.rb +3 -3
  19. data/lib/commands/server.rb +23 -54
  20. data/lib/commands/servers/lighttpd.rb +56 -0
  21. data/lib/commands/servers/webrick.rb +59 -0
  22. data/lib/dispatcher.rb +30 -8
  23. data/lib/fcgi_handler.rb +6 -1
  24. data/lib/initializer.rb +107 -42
  25. data/lib/rails_generator/generators/applications/app/app_generator.rb +14 -12
  26. data/lib/rails_generator/generators/components/migration/migration_generator.rb +52 -5
  27. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +2 -2
  28. data/lib/rails_generator/generators/components/model/templates/unit_test.rb +1 -5
  29. data/lib/rails_generator/generators/components/plugin/USAGE +33 -0
  30. data/lib/rails_generator/generators/components/plugin/plugin_generator.rb +33 -0
  31. data/lib/rails_generator/generators/components/plugin/templates/README +4 -0
  32. data/lib/rails_generator/generators/components/plugin/templates/Rakefile +22 -0
  33. data/lib/rails_generator/generators/components/plugin/templates/USAGE +8 -0
  34. data/lib/rails_generator/generators/components/plugin/templates/generator.rb +8 -0
  35. data/lib/rails_generator/generators/components/plugin/templates/init.rb +1 -0
  36. data/lib/rails_generator/generators/components/plugin/templates/plugin.rb +1 -0
  37. data/lib/rails_generator/generators/components/plugin/templates/tasks.rake +4 -0
  38. data/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +8 -0
  39. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +6 -1
  40. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +1 -1
  41. data/lib/rails_generator/generators/components/scaffold/templates/style.css +1 -1
  42. data/lib/rails_generator/lookup.rb +1 -0
  43. data/lib/rails_info.rb +94 -0
  44. data/lib/rails_version.rb +1 -1
  45. data/lib/tasks/databases.rake +8 -5
  46. data/lib/tasks/documentation.rake +34 -1
  47. data/lib/tasks/framework.rake +50 -12
  48. data/lib/tasks/misc.rake +5 -1
  49. data/lib/tasks/rails.rb +2 -2
  50. data/lib/tasks/testing.rake +14 -1
  51. metadata +28 -9
  52. data/html/javascripts/scriptaculous.js +0 -47
  53. data/html/javascripts/slider.js +0 -258
@@ -44,7 +44,9 @@ task :db_structure_dump => :environment do
44
44
  ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"]
45
45
  ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"]
46
46
  ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"]
47
- `pg_dump -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{abcs[RAILS_ENV]["database"]}`
47
+ search_path = abcs[RAILS_ENV]["schema_search_path"]
48
+ search_path = "--schema=#{search_path}" if search_path
49
+ `pg_dump -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{search_path} #{abcs[RAILS_ENV]["database"]}`
48
50
  when "sqlite", "sqlite3"
49
51
  `#{abcs[RAILS_ENV]["adapter"]} #{abcs[RAILS_ENV]["dbfile"]} .schema > db/#{RAILS_ENV}_structure.sql`
50
52
  when "sqlserver"
@@ -53,7 +55,7 @@ task :db_structure_dump => :environment do
53
55
  else
54
56
  raise "Task not supported by '#{abcs["test"]["adapter"]}'"
55
57
  end
56
-
58
+
57
59
  if ActiveRecord::Base.connection.supports_migrations?
58
60
  File.open("db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
59
61
  end
@@ -63,7 +65,7 @@ desc "Recreate the test databases from the development structure"
63
65
  task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
64
66
  abcs = ActiveRecord::Base.configurations
65
67
  case abcs["test"]["adapter"]
66
- when "mysql"
68
+ when "mysql"
67
69
  ActiveRecord::Base.establish_connection(:test)
68
70
  ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
69
71
  IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
@@ -78,7 +80,7 @@ task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
78
80
  `#{abcs["test"]["adapter"]} #{abcs["test"]["dbfile"]} < db/#{RAILS_ENV}_structure.sql`
79
81
  when "sqlserver"
80
82
  `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
81
- when "oci",
83
+ when "oci"
82
84
  ActiveRecord::Base.establish_connection(:test)
83
85
  IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
84
86
  ActiveRecord::Base.connection.execute(ddl)
@@ -99,8 +101,9 @@ task :purge_test_database => :environment do
99
101
  ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
100
102
  ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
101
103
  ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
104
+ enc_option = "-E #{abcs["test"]["encoding"]}" if abcs["test"]["encoding"]
102
105
  `dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
103
- `createdb -T template0 -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
106
+ `createdb #{enc_option} -T template0 -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
104
107
  when "sqlite","sqlite3"
105
108
  File.delete(abcs["test"]["dbfile"]) if File.exist?(abcs["test"]["dbfile"])
106
109
  when "sqlserver"
@@ -7,6 +7,39 @@ Rake::RDocTask.new("appdoc") { |rdoc|
7
7
  rdoc.rdoc_files.include('app/**/*.rb')
8
8
  }
9
9
 
10
+ Plugins = FileList['vendor/plugins/**'].map {|plugin| File.basename(plugin)}
11
+ # Define doc tasks for each plugin
12
+ Plugins.each do |plugin|
13
+ task :"#{plugin}_plugindoc" => :environment do
14
+ plugin_base = "vendor/plugins/#{plugin}"
15
+ options = []
16
+ files = Rake::FileList.new
17
+ options << "-o doc/plugins/#{plugin}"
18
+ options << "--title '#{plugin.titlecase} Plugin Documentation'"
19
+ options << '--line-numbers --inline-source'
20
+ options << '-T html'
21
+
22
+ files.include("#{plugin_base}/lib/**/*.rb")
23
+ if File.exists?("#{plugin_base}/README")
24
+ files.include("#{plugin_base}/README")
25
+ options << "--main '#{plugin_base}/README'"
26
+ end
27
+ files.include("#{plugin_base}/CHANGELOG") if File.exists?("#{plugin_base}/CHANGELOG")
28
+
29
+ options << files.to_s
30
+
31
+ sh %(rdoc #{options * ' '})
32
+ end
33
+ end
34
+
35
+ desc "Generate documation for all installed plugins"
36
+ task :plugindoc => Plugins.map {|plugin| :"#{plugin}_plugindoc"}
37
+
38
+ desc "Remove plugin documentation"
39
+ task :clobber_plugindoc do
40
+ rm_rf 'doc/plugins' rescue nil
41
+ end
42
+
10
43
  desc "Generate documentation for the Rails framework"
11
44
  Rake::RDocTask.new("apidoc") { |rdoc|
12
45
  rdoc.rdoc_dir = 'doc/api'
@@ -41,4 +74,4 @@ Rake::RDocTask.new("apidoc") { |rdoc|
41
74
  rdoc.rdoc_files.include('vendor/rails/activesupport/README')
42
75
  rdoc.rdoc_files.include('vendor/rails/activesupport/CHANGELOG')
43
76
  rdoc.rdoc_files.include('vendor/rails/activesupport/lib/active_support/**/*.rb')
44
- }
77
+ }
@@ -2,32 +2,70 @@ desc "Lock this application to the current gems (by unpacking them into vendor/r
2
2
  task :freeze_gems do
3
3
  rm_rf "vendor/rails"
4
4
  mkdir_p "vendor/rails"
5
-
6
- for gem in %w( actionpack activerecord actionmailer activesupport actionwebservice )
7
- system "cd vendor/rails; gem unpack #{gem}"
8
- FileUtils.mv(Dir.glob("vendor/rails/#{gem}*").first, "vendor/rails/#{gem}")
5
+
6
+ deps = %w( actionpack activerecord actionmailer activesupport actionwebservice )
7
+ if version = ENV['VERSION']
8
+ puts "Freezing to the gems for Rails #{version}"
9
+ require 'rubygems'
10
+ if rails = Gem.cache.search('rails', "= #{version}")
11
+ rails.dependencies.select { |g| deps.include? g.name }.each do |g|
12
+ system "cd vendor/rails; gem unpack -v '#{g.version_requirements}' #{g.name}; mv #{g.name}* #{g.name}"
13
+ end
14
+ system "cd vendor/rails; gem unpack -v '= #{version}' rails"
15
+ else
16
+ puts "No rails gem version #{version} is installed. Do 'gem list rails' to see which versions you have available."
17
+ exit
18
+ end
19
+ else
20
+ puts "Freezing to your latest Rails gems"
21
+ for gem in deps
22
+ system "cd vendor/rails; gem unpack #{gem}"
23
+ FileUtils.mv(Dir.glob("vendor/rails/#{gem}*").first, "vendor/rails/#{gem}")
24
+ end
25
+ system "cd vendor/rails; gem unpack rails"
9
26
  end
10
-
11
- system "cd vendor/rails; gem unpack rails"
12
27
  FileUtils.mv(Dir.glob("vendor/rails/rails*").first, "vendor/rails/railties")
13
28
  end
14
29
 
15
- desc "Lock this application to the Edge Rails (by exporting from Subversion)"
30
+ desc "Lock this application to the Edge Rails (by exporting from Subversion). Defaults to svn HEAD; do 'rake freeze_edge REVISION=1234' to lock to a specific revision."
16
31
  task :freeze_edge do
17
- $stderr.close
18
- svn_available = `svn --version`.size > 0
19
- raise "Subversion is not installed" unless svn_available
32
+ $verbose = false
33
+ `svn --version` rescue nil
34
+ unless !$?.nil? && $?.success?
35
+ $stderr.puts "ERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Rails"
36
+ exit 1
37
+ end
20
38
 
21
39
  rm_rf "vendor/rails"
22
40
  mkdir_p "vendor/rails"
23
-
41
+
42
+ revision_switch = ENV['REVISION'] ? " -r #{ENV['REVISION']}" : ''
24
43
  for framework in %w( railties actionpack activerecord actionmailer activesupport actionwebservice )
25
44
  mkdir_p "vendor/rails/#{framework}"
26
- system "svn export http://dev.rubyonrails.org/svn/rails/trunk/#{framework}/lib vendor/rails/#{framework}/lib"
45
+ system "svn export http://dev.rubyonrails.org/svn/rails/trunk/#{framework}/lib vendor/rails/#{framework}/lib #{revision_switch}"
27
46
  end
28
47
  end
29
48
 
30
49
  desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems"
31
50
  task :unfreeze_rails do
32
51
  rm_rf "vendor/rails"
52
+ end
53
+
54
+ desc "Add new scripts to the application script/ directory"
55
+ task :add_new_scripts do
56
+ local_base = "script"
57
+ edge_base = "#{File.dirname(__FILE__)}/../../bin"
58
+
59
+ local = Dir["#{local_base}/**/*"].reject { |path| File.directory?(path) }
60
+ edge = Dir["#{edge_base}/**/*"].reject { |path| File.directory?(path) }
61
+
62
+ edge.each do |script|
63
+ base_name = script[(edge_base.length+1)..-1]
64
+ next if base_name == "rails"
65
+ next if local.detect { |path| base_name == path[(local_base.length+1)..-1] }
66
+ if !File.directory?("#{local_base}/#{File.dirname(base_name)}")
67
+ mkdir_p "#{local_base}/#{File.dirname(base_name)}"
68
+ end
69
+ install script, "#{local_base}/#{base_name}", :mode => 0655
70
+ end
33
71
  end
@@ -1,5 +1,9 @@
1
1
  desc "Run all the tests on a fresh test database"
2
- task :default => [ :test_units, :test_functional ]
2
+ task :default do
3
+ Rake::Task[:test_units].invoke rescue got_error = true
4
+ Rake::Task[:test_functional].invoke rescue got_error = true
5
+ raise "Test failures" if got_error
6
+ end
3
7
 
4
8
  task :environment do
5
9
  require(File.join(RAILS_ROOT, 'config', 'environment'))
@@ -4,5 +4,5 @@ $VERBOSE = nil
4
4
  Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
5
5
 
6
6
  # Load any custom rakefile extensions
7
- Dir["./lib/tasks/**/*.rake"].each { |ext| load ext }
8
- Dir["./vendor/plugins/*/tasks/**/*.rake"].each { |ext| load ext }
7
+ Dir["./lib/tasks/**/*.rake"].sort.each { |ext| load ext }
8
+ Dir["./vendor/plugins/*/tasks/**/*.rake"].sort.each { |ext| load ext }
@@ -34,4 +34,17 @@ Rake::TestTask.new(:test_functional => [ :prepare_test_database ]) do |t|
34
34
  t.libs << "test"
35
35
  t.pattern = 'test/functional/**/*_test.rb'
36
36
  t.verbose = true
37
- end
37
+ end
38
+
39
+ desc "Run the plugin tests in vendor/plugins/**/test (or specify with PLUGIN=name)"
40
+ Rake::TestTask.new(:test_plugins => :environment) do |t|
41
+ t.libs << "test"
42
+
43
+ if ENV['PLUGIN']
44
+ t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb"
45
+ else
46
+ t.pattern = 'vendor/plugins/**/test/**/*_test.rb'
47
+ end
48
+
49
+ t.verbose = true
50
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rails
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.14.2
7
- date: 2005-10-26 00:00:00 +02:00
6
+ version: 0.14.3
7
+ date: 2005-11-07 00:00:00 +01:00
8
8
  summary: "Web-application framework with template engine, control-flow layer, and ORM."
9
9
  require_paths:
10
10
  - lib
@@ -45,11 +45,13 @@ files:
45
45
  - Rakefile
46
46
  - README
47
47
  - test
48
+ - bin/about
48
49
  - bin/breakpointer
49
50
  - bin/console
50
51
  - bin/destroy
51
52
  - bin/generate
52
53
  - bin/performance
54
+ - bin/plugin
53
55
  - bin/process
54
56
  - bin/rails
55
57
  - bin/runner
@@ -62,6 +64,7 @@ files:
62
64
  - configs/apache.conf
63
65
  - configs/database.yml
64
66
  - configs/empty.log
67
+ - configs/lighttpd.conf
65
68
  - configs/routes.rb
66
69
  - doc/README_FOR_APP
67
70
  - dispatches/dispatch.fcgi
@@ -85,8 +88,6 @@ files:
85
88
  - html/javascripts/dragdrop.js
86
89
  - html/javascripts/effects.js
87
90
  - html/javascripts/prototype.js
88
- - html/javascripts/scriptaculous.js
89
- - html/javascripts/slider.js
90
91
  - lib/binding_of_caller.rb
91
92
  - lib/breakpoint.rb
92
93
  - lib/breakpoint_client.rb
@@ -99,21 +100,25 @@ files:
99
100
  - lib/initializer.rb
100
101
  - lib/rails_generator
101
102
  - lib/rails_generator.rb
103
+ - lib/rails_info.rb
102
104
  - lib/rails_version.rb
103
105
  - lib/railties_path.rb
104
106
  - lib/rubyprof_ext.rb
105
107
  - lib/tasks
106
108
  - lib/test_help.rb
107
109
  - lib/webrick_server.rb
110
+ - lib/commands/about.rb
108
111
  - lib/commands/breakpointer.rb
109
112
  - lib/commands/console.rb
110
113
  - lib/commands/destroy.rb
111
114
  - lib/commands/generate.rb
112
115
  - lib/commands/ncgi
113
116
  - lib/commands/performance
117
+ - lib/commands/plugin.rb
114
118
  - lib/commands/process
115
119
  - lib/commands/runner.rb
116
120
  - lib/commands/server.rb
121
+ - lib/commands/servers
117
122
  - lib/commands/update.rb
118
123
  - lib/commands/ncgi/listener
119
124
  - lib/commands/ncgi/tracker
@@ -122,6 +127,8 @@ files:
122
127
  - lib/commands/process/reaper.rb
123
128
  - lib/commands/process/spawner.rb
124
129
  - lib/commands/process/spinner.rb
130
+ - lib/commands/servers/lighttpd.rb
131
+ - lib/commands/servers/webrick.rb
125
132
  - lib/rails_generator/base.rb
126
133
  - lib/rails_generator/commands.rb
127
134
  - lib/rails_generator/generators
@@ -141,6 +148,7 @@ files:
141
148
  - lib/rails_generator/generators/components/mailer
142
149
  - lib/rails_generator/generators/components/migration
143
150
  - lib/rails_generator/generators/components/model
151
+ - lib/rails_generator/generators/components/plugin
144
152
  - lib/rails_generator/generators/components/scaffold
145
153
  - lib/rails_generator/generators/components/web_service
146
154
  - lib/rails_generator/generators/components/controller/controller_generator.rb
@@ -167,6 +175,17 @@ files:
167
175
  - lib/rails_generator/generators/components/model/templates/fixtures.yml
168
176
  - lib/rails_generator/generators/components/model/templates/model.rb
169
177
  - lib/rails_generator/generators/components/model/templates/unit_test.rb
178
+ - lib/rails_generator/generators/components/plugin/plugin_generator.rb
179
+ - lib/rails_generator/generators/components/plugin/templates
180
+ - lib/rails_generator/generators/components/plugin/USAGE
181
+ - lib/rails_generator/generators/components/plugin/templates/generator.rb
182
+ - lib/rails_generator/generators/components/plugin/templates/init.rb
183
+ - lib/rails_generator/generators/components/plugin/templates/plugin.rb
184
+ - lib/rails_generator/generators/components/plugin/templates/Rakefile
185
+ - lib/rails_generator/generators/components/plugin/templates/README
186
+ - lib/rails_generator/generators/components/plugin/templates/tasks.rake
187
+ - lib/rails_generator/generators/components/plugin/templates/unit_test.rb
188
+ - lib/rails_generator/generators/components/plugin/templates/USAGE
170
189
  - lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
171
190
  - lib/rails_generator/generators/components/scaffold/templates
172
191
  - lib/rails_generator/generators/components/scaffold/USAGE
@@ -226,7 +245,7 @@ dependencies:
226
245
  -
227
246
  - "="
228
247
  - !ruby/object:Gem::Version
229
- version: 1.2.2
248
+ version: 1.2.3
230
249
  version:
231
250
  - !ruby/object:Gem::Dependency
232
251
  name: activerecord
@@ -236,7 +255,7 @@ dependencies:
236
255
  -
237
256
  - "="
238
257
  - !ruby/object:Gem::Version
239
- version: 1.12.2
258
+ version: 1.13.0
240
259
  version:
241
260
  - !ruby/object:Gem::Dependency
242
261
  name: actionpack
@@ -246,7 +265,7 @@ dependencies:
246
265
  -
247
266
  - "="
248
267
  - !ruby/object:Gem::Version
249
- version: 1.10.2
268
+ version: 1.11.0
250
269
  version:
251
270
  - !ruby/object:Gem::Dependency
252
271
  name: actionmailer
@@ -256,7 +275,7 @@ dependencies:
256
275
  -
257
276
  - "="
258
277
  - !ruby/object:Gem::Version
259
- version: 1.1.2
278
+ version: 1.1.3
260
279
  version:
261
280
  - !ruby/object:Gem::Dependency
262
281
  name: actionwebservice
@@ -266,5 +285,5 @@ dependencies:
266
285
  -
267
286
  - "="
268
287
  - !ruby/object:Gem::Version
269
- version: 0.9.2
288
+ version: 0.9.3
270
289
  version:
@@ -1,47 +0,0 @@
1
- // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining
4
- // a copy of this software and associated documentation files (the
5
- // "Software"), to deal in the Software without restriction, including
6
- // without limitation the rights to use, copy, modify, merge, publish,
7
- // distribute, sublicense, and/or sell copies of the Software, and to
8
- // permit persons to whom the Software is furnished to do so, subject to
9
- // the following conditions:
10
- //
11
- // The above copyright notice and this permission notice shall be
12
- // included in all copies or substantial portions of the Software.
13
- //
14
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- var Scriptaculous = {
23
- Version: '1.5_rc3',
24
- require: function(libraryName) {
25
- // inserting via DOM fails in Safari 2.0, so brute force approach
26
- document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
27
- },
28
- load: function() {
29
- if((typeof Prototype=='undefined') ||
30
- parseFloat(Prototype.Version.split(".")[0] + "." +
31
- Prototype.Version.split(".")[1]) < 1.4)
32
- throw("script.aculo.us requires the Prototype JavaScript framework >= 1.4.0");
33
- var scriptTags = document.getElementsByTagName("script");
34
- for(var i=0;i<scriptTags.length;i++) {
35
- if(scriptTags[i].src && scriptTags[i].src.match(/scriptaculous\.js(\?.*)?$/)) {
36
- var path = scriptTags[i].src.replace(/scriptaculous\.js(\?.*)?$/,'');
37
- this.require(path + 'effects.js');
38
- this.require(path + 'dragdrop.js');
39
- this.require(path + 'controls.js');
40
- this.require(path + 'slider.js');
41
- break;
42
- }
43
- }
44
- }
45
- }
46
-
47
- Scriptaculous.load();
@@ -1,258 +0,0 @@
1
- // Copyright (c) 2005 Marty Haught
2
- //
3
- // See scriptaculous.js for full license.
4
-
5
- if(!Control) var Control = {};
6
- Control.Slider = Class.create();
7
-
8
- // options:
9
- // axis: 'vertical', or 'horizontal' (default)
10
- // increment: (default: 1)
11
- // step: (default: 1)
12
- //
13
- // callbacks:
14
- // onChange(value)
15
- // onSlide(value)
16
- Control.Slider.prototype = {
17
- initialize: function(handle, track, options) {
18
- this.handle = $(handle);
19
- this.track = $(track);
20
-
21
- this.options = options || {};
22
-
23
- this.axis = this.options.axis || 'horizontal';
24
- this.increment = this.options.increment || 1;
25
- this.step = parseInt(this.options.step) || 1;
26
- this.value = 0;
27
-
28
- var defaultMaximum = Math.round(this.track.offsetWidth / this.increment);
29
- if(this.isVertical()) defaultMaximum = Math.round(this.track.offsetHeight / this.increment);
30
-
31
- this.maximum = this.options.maximum || defaultMaximum;
32
- this.minimum = this.options.minimum || 0;
33
-
34
- // Will be used to align the handle onto the track, if necessary
35
- this.alignX = parseInt (this.options.alignX) || 0;
36
- this.alignY = parseInt (this.options.alignY) || 0;
37
-
38
- // Zero out the slider position
39
- this.setCurrentLeft(Position.cumulativeOffset(this.track)[0] - Position.cumulativeOffset(this.handle)[0] + this.alignX);
40
- this.setCurrentTop(this.trackTop() - Position.cumulativeOffset(this.handle)[1] + this.alignY);
41
-
42
- this.offsetX = 0;
43
- this.offsetY = 0;
44
-
45
- this.originalLeft = this.currentLeft();
46
- this.originalTop = this.currentTop();
47
- this.originalZ = parseInt(this.handle.style.zIndex || "0");
48
-
49
- // Prepopulate Slider value
50
- this.setSliderValue(parseInt(this.options.sliderValue) || 0);
51
-
52
- this.active = false;
53
- this.dragging = false;
54
- this.disabled = false;
55
-
56
- // FIXME: use css
57
- this.handleImage = $(this.options.handleImage) || false;
58
- this.handleDisabled = this.options.handleDisabled || false;
59
- this.handleEnabled = false;
60
- if(this.handleImage)
61
- this.handleEnabled = this.handleImage.src || false;
62
-
63
- if(this.options.disabled)
64
- this.setDisabled();
65
-
66
- // Value Array
67
- this.values = this.options.values || false; // Add method to validate and sort??
68
-
69
- Element.makePositioned(this.handle); // fix IE
70
-
71
- this.eventMouseDown = this.startDrag.bindAsEventListener(this);
72
- this.eventMouseUp = this.endDrag.bindAsEventListener(this);
73
- this.eventMouseMove = this.update.bindAsEventListener(this);
74
- this.eventKeypress = this.keyPress.bindAsEventListener(this);
75
-
76
- Event.observe(this.handle, "mousedown", this.eventMouseDown);
77
- Event.observe(document, "mouseup", this.eventMouseUp);
78
- Event.observe(document, "mousemove", this.eventMouseMove);
79
- Event.observe(document, "keypress", this.eventKeypress);
80
- },
81
- dispose: function() {
82
- Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
83
- Event.stopObserving(document, "mouseup", this.eventMouseUp);
84
- Event.stopObserving(document, "mousemove", this.eventMouseMove);
85
- Event.stopObserving(document, "keypress", this.eventKeypress);
86
- },
87
- setDisabled: function(){
88
- this.disabled = true;
89
- if(this.handleDisabled)
90
- this.handleImage.src = this.handleDisabled;
91
- },
92
- setEnabled: function(){
93
- this.disabled = false;
94
- if(this.handleEnabled)
95
- this.handleImage.src = this.handleEnabled;
96
- },
97
- currentLeft: function() {
98
- return parseInt(this.handle.style.left || '0');
99
- },
100
- currentTop: function() {
101
- return parseInt(this.handle.style.top || '0');
102
- },
103
- setCurrentLeft: function(left) {
104
- this.handle.style.left = left +"px";
105
- },
106
- setCurrentTop: function(top) {
107
- this.handle.style.top = top +"px";
108
- },
109
- trackLeft: function(){
110
- return Position.cumulativeOffset(this.track)[0];
111
- },
112
- trackTop: function(){
113
- return Position.cumulativeOffset(this.track)[1];
114
- },
115
- getNearestValue: function(value){
116
- if(this.values){
117
- var i = 0;
118
- var offset = Math.abs(this.values[0] - value);
119
- var newValue = this.values[0];
120
-
121
- for(i=0; i < this.values.length; i++){
122
- var currentOffset = Math.abs(this.values[i] - value);
123
- if(currentOffset < offset){
124
- newValue = this.values[i];
125
- offset = currentOffset;
126
- }
127
- }
128
- return newValue;
129
- }
130
- return value;
131
- },
132
- setSliderValue: function(sliderValue){
133
- // First check our max and minimum and nearest values
134
- sliderValue = this.getNearestValue(sliderValue);
135
- if(sliderValue > this.maximum) sliderValue = this.maximum;
136
- if(sliderValue < this.minimum) sliderValue = this.minimum;
137
- var offsetDiff = (sliderValue - (this.value||this.minimum)) * this.increment;
138
-
139
- if(this.isVertical()){
140
- this.setCurrentTop(offsetDiff + this.currentTop());
141
- } else {
142
- this.setCurrentLeft(offsetDiff + this.currentLeft());
143
- }
144
- this.value = sliderValue;
145
- this.updateFinished();
146
- },
147
- minimumOffset: function(){
148
- return(this.isVertical() ?
149
- this.trackTop() + this.alignY :
150
- this.trackLeft() + this.alignX);
151
- },
152
- maximumOffset: function(){
153
- return(this.isVertical() ?
154
- this.trackTop() + this.alignY + (this.maximum - this.minimum) * this.increment :
155
- this.trackLeft() + this.alignX + (this.maximum - this.minimum) * this.increment);
156
- },
157
- isVertical: function(){
158
- return (this.axis == 'vertical');
159
- },
160
- startDrag: function(event) {
161
- if(Event.isLeftClick(event)) {
162
- if(!this.disabled){
163
- this.active = true;
164
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
165
- var offsets = Position.cumulativeOffset(this.handle);
166
- this.offsetX = (pointer[0] - offsets[0]);
167
- this.offsetY = (pointer[1] - offsets[1]);
168
- this.originalLeft = this.currentLeft();
169
- this.originalTop = this.currentTop();
170
- }
171
- Event.stop(event);
172
- }
173
- },
174
- update: function(event) {
175
- if(this.active) {
176
- if(!this.dragging) {
177
- var style = this.handle.style;
178
- this.dragging = true;
179
- if(style.position=="") style.position = "relative";
180
- style.zIndex = this.options.zindex;
181
- }
182
- this.draw(event);
183
- // fix AppleWebKit rendering
184
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
185
- Event.stop(event);
186
- }
187
- },
188
- draw: function(event) {
189
- var pointer = [Event.pointerX(event), Event.pointerY(event)];
190
- var offsets = Position.cumulativeOffset(this.handle);
191
-
192
- offsets[0] -= this.currentLeft();
193
- offsets[1] -= this.currentTop();
194
-
195
- // Adjust for the pointer's position on the handle
196
- pointer[0] -= this.offsetX;
197
- pointer[1] -= this.offsetY;
198
- var style = this.handle.style;
199
-
200
- if(this.isVertical()){
201
- if(pointer[1] > this.maximumOffset())
202
- pointer[1] = this.maximumOffset();
203
- if(pointer[1] < this.minimumOffset())
204
- pointer[1] = this.minimumOffset();
205
-
206
- // Increment by values
207
- if(this.values){
208
- this.value = this.getNearestValue(Math.round((pointer[1] - this.minimumOffset()) / this.increment) + this.minimum);
209
- pointer[1] = this.trackTop() + this.alignY + (this.value - this.minimum) * this.increment;
210
- } else {
211
- this.value = Math.round((pointer[1] - this.minimumOffset()) / this.increment) + this.minimum;
212
- }
213
- style.top = pointer[1] - offsets[1] + "px";
214
- } else {
215
- if(pointer[0] > this.maximumOffset()) pointer[0] = this.maximumOffset();
216
- if(pointer[0] < this.minimumOffset()) pointer[0] = this.minimumOffset();
217
- // Increment by values
218
- if(this.values){
219
- this.value = this.getNearestValue(Math.round((pointer[0] - this.minimumOffset()) / this.increment) + this.minimum);
220
- pointer[0] = this.trackLeft() + this.alignX + (this.value - this.minimum) * this.increment;
221
- } else {
222
- this.value = Math.round((pointer[0] - this.minimumOffset()) / this.increment) + this.minimum;
223
- }
224
- style.left = (pointer[0] - offsets[0]) + "px";
225
- }
226
- if(this.options.onSlide) this.options.onSlide(this.value);
227
- },
228
- endDrag: function(event) {
229
- if(this.active && this.dragging) {
230
- this.finishDrag(event, true);
231
- Event.stop(event);
232
- }
233
- this.active = false;
234
- this.dragging = false;
235
- },
236
- finishDrag: function(event, success) {
237
- this.active = false;
238
- this.dragging = false;
239
- this.handle.style.zIndex = this.originalZ;
240
- this.originalLeft = this.currentLeft();
241
- this.originalTop = this.currentTop();
242
- this.updateFinished();
243
- },
244
- updateFinished: function() {
245
- if(this.options.onChange) this.options.onChange(this.value);
246
- },
247
- keyPress: function(event) {
248
- if(this.active && !this.disabled) {
249
- switch(event.keyCode) {
250
- case Event.KEY_ESC:
251
- this.finishDrag(event, false);
252
- Event.stop(event);
253
- break;
254
- }
255
- if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event);
256
- }
257
- }
258
- }