compages 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.project +18 -0
- data/README +180 -0
- data/Rakefile +10 -0
- data/app/controllers/application.rb +4 -0
- data/app/controllers/contents_controller.rb +116 -0
- data/app/controllers/pages_controller.rb +59 -0
- data/app/controllers/render_controller.rb +24 -0
- data/app/helpers/application_helper.rb +6 -0
- data/app/helpers/contents_helper.rb +5 -0
- data/app/helpers/pages_helper.rb +5 -0
- data/app/helpers/render_helper.rb +2 -0
- data/app/models/content.rb +26 -0
- data/app/models/meta_data.rb +3 -0
- data/app/models/page.rb +106 -0
- data/app/models/page_element.rb +9 -0
- data/app/views/contents/_content_preview.rhtml +1 -0
- data/app/views/contents/_contents_list.rhtml +3 -0
- data/app/views/contents/_show_library.rhtml +60 -0
- data/app/views/contents/_write_now.rhtml +42 -0
- data/app/views/layouts/pages.rhtml +24 -0
- data/app/views/layouts/render.rhtml +11 -0
- data/app/views/pages/_change_theme.rhtml +0 -0
- data/app/views/pages/_edit_menu.rhtml +62 -0
- data/app/views/pages/_page_listed.rhtml +13 -0
- data/app/views/pages/_select_theme.rhtml +4 -0
- data/app/views/pages/edit.rhtml +35 -0
- data/app/views/pages/index.rhtml +45 -0
- data/app/views/pages/list.rhtml +41 -0
- data/app/views/pages/list_a.rhtml +40 -0
- data/app/views/pages/welcome.rhtml +27 -0
- data/app/views/render/_blank.rhtml +3 -0
- data/app/views/render/show.rhtml +1 -0
- data/bin/compages +14 -0
- data/config/boot.rb +44 -0
- data/config/database.yml.home +35 -0
- data/config/environment.rb +53 -0
- data/config/environments/development.rb +21 -0
- data/config/environments/production.rb +18 -0
- data/config/environments/test.rb +19 -0
- data/config/routes.rb +32 -0
- data/db/Copia di schema.rb +48 -0
- data/db/migrate/001_create_pages.rb +12 -0
- data/db/migrate/002_create_contents.rb +12 -0
- data/db/migrate/003_create_meta_datas.rb +14 -0
- data/db/migrate/004_create_page_elements.rb +17 -0
- data/db/migrate/005_add_urlnames.rb +15 -0
- data/db/migrate/006_add_sessions.rb +15 -0
- data/db/schema.mysql.sql +65 -0
- data/db/schema.postgresql.sql +65 -0
- data/db/schema.rb +49 -0
- data/db/schema.sqlite.sql +65 -0
- data/db/schema.sqlserver.sql +71 -0
- data/db/schema_version +1 -0
- data/doc/ER-model/v1.dia +0 -0
- data/doc/ER-model/v2.dia +0 -0
- data/doc/ER-model/v3.dia +0 -0
- data/doc/README_FOR_APP +2 -0
- data/doc/esempi/doc-vir/ecds.htm +2362 -0
- data/doc/esempi/doc-vir/ecds_files/search.gif +0 -0
- data/doc/esempi/doc-vir/ecds_files/upld.gif +0 -0
- data/doc/esempi/doc-vir/ecds_files/upld.jpg +0 -0
- data/installer/apache13.conf.example.template +33 -0
- data/installer/apache20.conf.example.template +40 -0
- data/installer/lighttpd.conf.example.template +6 -0
- data/installer/rails_installer_defaults.yml +5 -0
- data/lib/redcloth.rb +1130 -0
- data/lib/render_engine.rb +94 -0
- data/lib/tasks/release.rake +46 -0
- data/public/.htaccess +41 -0
- data/public/404.html +8 -0
- data/public/500.html +8 -0
- data/public/_index.html +277 -0
- data/public/favicon.ico +0 -0
- data/public/images/body_bg.gif +0 -0
- data/public/images/body_bg_short.gif +0 -0
- data/public/images/ie_shadow.png +0 -0
- data/public/images/journal_reflex.gif +0 -0
- data/public/images/journal_shadow.gif +0 -0
- data/public/images/logo_journal_small.bmp +0 -0
- data/public/images/logo_journal_small.png +0 -0
- data/public/images/page_edit_shadow.png +0 -0
- data/public/images/restore_bar.png +0 -0
- data/public/images/spinner.gif +0 -0
- data/public/javascripts/application.js +23 -0
- data/public/javascripts/controls.js +815 -0
- data/public/javascripts/dragdrop.js +913 -0
- data/public/javascripts/effects.js +958 -0
- data/public/javascripts/lowpro.js +307 -0
- data/public/javascripts/prototype.js +2006 -0
- data/public/robots.txt +1 -0
- data/public/stylesheets/compages.css +196 -0
- data/public/stylesheets/editing.css +180 -0
- data/public/stylesheets/editing_ie_filth.css +36 -0
- data/public/themes/Doc_basic/_script.js +342 -0
- data/public/themes/Doc_basic/images/Thumbs.db +0 -0
- data/public/themes/Doc_basic/images/search.gif +0 -0
- data/public/themes/Doc_basic/images/upld.gif +0 -0
- data/public/themes/Doc_basic/images/upld.jpg +0 -0
- data/public/themes/Doc_basic/index.html +114 -0
- data/public/themes/Doc_basic/style.css +1743 -0
- data/public/themes/color7boxes/default2.css +42 -0
- data/public/themes/color7boxes/index.html +40 -0
- data/public/themes/prova/index.html +12 -0
- data/public/zDoc/images/search.gif +0 -0
- data/public/zDoc/images/upld.gif +0 -0
- data/public/zDoc/images/upld.jpg +0 -0
- data/public/zDoc/index.html +176 -0
- data/public/zDoc/script.js +342 -0
- data/public/zDoc/style.css +1741 -0
- data/script/about +3 -0
- data/script/breakpointer +3 -0
- data/script/console +3 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/plugin +3 -0
- data/script/process/reaper +3 -0
- data/script/process/spawner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/test/fixtures/contents.yml +5 -0
- data/test/fixtures/meta_datas.yml +5 -0
- data/test/fixtures/page_elements.yml +5 -0
- data/test/fixtures/pages.yml +5 -0
- data/test/functional/contents_controller_test.rb +18 -0
- data/test/functional/pages_controller_test.rb +18 -0
- data/test/functional/render_controller_test.rb +18 -0
- data/test/test_helper.rb +28 -0
- data/test/unit/content_test.rb +10 -0
- data/test/unit/meta_data_test.rb +10 -0
- data/test/unit/page_element_test.rb +10 -0
- data/test/unit/page_test.rb +10 -0
- data/tmp/sessions/ruby_sess.0ced4c30e36477ab +0 -0
- data/tmp/sessions/ruby_sess.20fbe26671422e70 +0 -0
- data/tmp/sessions/ruby_sess.2c72521f3a7e2ba9 +0 -0
- data/tmp/sessions/ruby_sess.4107a69d982a2eb7 +0 -0
- data/tmp/sessions/ruby_sess.573ded9c7fdd9035 +0 -0
- data/tmp/sessions/ruby_sess.5a9767815bb96258 +0 -0
- data/tmp/sessions/ruby_sess.85d723b794005388 +0 -0
- data/tmp/sessions/ruby_sess.875b3b3e3529afdb +0 -0
- data/tmp/sessions/ruby_sess.936766f3a397c88b +0 -0
- data/tmp/sessions/ruby_sess.984e2e4c9a2e7891 +0 -0
- data/tmp/sessions/ruby_sess.a1faebd7448bc45d +0 -0
- data/tmp/sessions/ruby_sess.a415768c7635bc15 +0 -0
- data/tmp/sessions/ruby_sess.b2dadcbe6c1b0add +0 -0
- data/tmp/sessions/ruby_sess.ca9100beb103a428 +0 -0
- data/tmp/sessions/ruby_sess.d649c800a046efde +0 -0
- data/tmp/sessions/ruby_sess.db73bbfafd5a537c +0 -0
- data/tmp/sessions/ruby_sess.e32487b847524df1 +0 -0
- data/tmp/sessions/ruby_sess.f4e45d67828cc437 +0 -0
- data/tmp/sessions/ruby_sess.f5a3f064f2f7a26f +0 -0
- data/tmp/sessions/ruby_sess.ff0c47b35f238cda +0 -0
- data/vendor/plugins/acts_as_urlnameable.tar.gz +0 -0
- data/vendor/plugins/acts_as_urlnameable/LICENSE +19 -0
- data/vendor/plugins/acts_as_urlnameable/README +193 -0
- data/vendor/plugins/acts_as_urlnameable/Rakefile +25 -0
- data/vendor/plugins/acts_as_urlnameable/TODO +5 -0
- data/vendor/plugins/acts_as_urlnameable/db/00x_add_urlnames_table.rb +15 -0
- data/vendor/plugins/acts_as_urlnameable/db/urlnames_table.sql +7 -0
- data/vendor/plugins/acts_as_urlnameable/doc/classes/ActiveRecord/Acts/Urlnameable/ClassMethods.html +167 -0
- data/vendor/plugins/acts_as_urlnameable/doc/classes/ActiveRecord/Acts/Urlnameable/InstanceMethods.html +213 -0
- data/vendor/plugins/acts_as_urlnameable/doc/classes/ActiveRecord/Acts/Urlnameable/SingletonMethods.html +189 -0
- data/vendor/plugins/acts_as_urlnameable/doc/created.rid +1 -0
- data/vendor/plugins/acts_as_urlnameable/doc/files/LICENSE.html +129 -0
- data/vendor/plugins/acts_as_urlnameable/doc/files/README.html +333 -0
- data/vendor/plugins/acts_as_urlnameable/doc/files/TODO.html +121 -0
- data/vendor/plugins/acts_as_urlnameable/doc/files/lib/acts_as_urlnameable_rb.html +101 -0
- data/vendor/plugins/acts_as_urlnameable/doc/fr_class_index.html +29 -0
- data/vendor/plugins/acts_as_urlnameable/doc/fr_file_index.html +30 -0
- data/vendor/plugins/acts_as_urlnameable/doc/fr_method_index.html +34 -0
- data/vendor/plugins/acts_as_urlnameable/doc/index.html +24 -0
- data/vendor/plugins/acts_as_urlnameable/doc/rdoc-style.css +208 -0
- data/vendor/plugins/acts_as_urlnameable/init.rb +3 -0
- data/vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb +159 -0
- data/vendor/plugins/acts_as_urlnameable/lib/urlname.rb +3 -0
- data/vendor/plugins/acts_as_urlnameable/test/acts_as_urlnameable_test.rb +233 -0
- data/vendor/plugins/acts_as_urlnameable/test/connection.rb +8 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/article.rb +13 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/articles.yml +62 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/page.rb +14 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/pages.yml +35 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/people.yml +9 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/person.rb +26 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/schema.rb +24 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/section.rb +5 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/sections.yml +9 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/urlnames.yml +153 -0
- data/vendor/plugins/acts_as_urlnameable/test/test_helper.rb +42 -0
- data/vendor/plugins/gems/README +30 -0
- data/vendor/plugins/gems/init.rb +9 -0
- data/vendor/plugins/gems/tasks/gems_tasks.rake +32 -0
- data/vendor/plugins/unobtrusive_javascript/CHANGELOG +72 -0
- data/vendor/plugins/unobtrusive_javascript/README +73 -0
- data/vendor/plugins/unobtrusive_javascript/Rakefile +33 -0
- data/vendor/plugins/unobtrusive_javascript/about.yml +6 -0
- data/vendor/plugins/unobtrusive_javascript/assets/javascripts/lowpro.js +307 -0
- data/vendor/plugins/unobtrusive_javascript/init.rb +21 -0
- data/vendor/plugins/unobtrusive_javascript/install.rb +1 -0
- data/vendor/plugins/unobtrusive_javascript/lib/actionview_helpers_patches.rb +17 -0
- data/vendor/plugins/unobtrusive_javascript/lib/asset_tag_helper_patches.rb +33 -0
- data/vendor/plugins/unobtrusive_javascript/lib/behaviour_caching.rb +70 -0
- data/vendor/plugins/unobtrusive_javascript/lib/controllers/unobtrusive_javascript_controller.rb +52 -0
- data/vendor/plugins/unobtrusive_javascript/lib/prototype_helper_patches.rb +72 -0
- data/vendor/plugins/unobtrusive_javascript/lib/scriptaculous_helper_patches.rb +62 -0
- data/vendor/plugins/unobtrusive_javascript/lib/tag_helper_patches.rb +37 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs.rb +32 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/behaviour_helper.rb +62 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/behaviour_script.rb +54 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/behaviour_script_converter.rb +23 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/controller_methods.rb +55 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/helpers.rb +152 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/javascript_proxies.rb +57 -0
- data/vendor/plugins/unobtrusive_javascript/tasks/unobtrusive_javascript_tasks.rake +15 -0
- data/vendor/plugins/unobtrusive_javascript/test/asset_tag_helper_patches_test.rb +32 -0
- data/vendor/plugins/unobtrusive_javascript/test/behaviour_helper_test.rb +180 -0
- data/vendor/plugins/unobtrusive_javascript/test/behaviour_script_converter_test.rb +72 -0
- data/vendor/plugins/unobtrusive_javascript/test/behaviour_script_test.rb +98 -0
- data/vendor/plugins/unobtrusive_javascript/test/config/environment.rb +8 -0
- data/vendor/plugins/unobtrusive_javascript/test/config/routes.rb +4 -0
- data/vendor/plugins/unobtrusive_javascript/test/config/schema.rb +3 -0
- data/vendor/plugins/unobtrusive_javascript/test/controller_methods_test.rb +48 -0
- data/vendor/plugins/unobtrusive_javascript/test/helpers_test.rb +186 -0
- data/vendor/plugins/unobtrusive_javascript/test/javascript_proxies_test.rb +3 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/boot.rb +26 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/action_controller.rb +11 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/action_mailer.rb +4 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/active_record.rb +27 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/rails.rb +31 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/ptk.rb +148 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/suite/difference.rb +23 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/stubs/controller_stub.rb +10 -0
- data/vendor/plugins/unobtrusive_javascript/test/ptk_helper.rb +29 -0
- data/vendor/plugins/unobtrusive_javascript/test/tag_helper_patches_test.rb +59 -0
- data/vendor/plugins/unobtrusive_javascript/test/test_helper.rb +25 -0
- data/vendor/plugins/unobtrusive_javascript/test/unobtrusive_javascript_controller_test.rb +95 -0
- data/vendor/plugins/unobtrusive_javascript/uninstall.rb +1 -0
- data/vendor/redcloth/bin/redcloth +3 -0
- data/vendor/redcloth/doc/CHANGELOG +160 -0
- data/vendor/redcloth/doc/COPYING +25 -0
- data/vendor/redcloth/doc/README +106 -0
- data/vendor/redcloth/doc/REFERENCE +216 -0
- data/vendor/redcloth/doc/make.rb +359 -0
- data/vendor/redcloth/lib/redcloth.rb +1130 -0
- data/vendor/redcloth/run-tests.rb +28 -0
- data/vendor/redcloth/setup.rb +1376 -0
- data/vendor/redcloth/tests/code.yml +105 -0
- data/vendor/redcloth/tests/hard_breaks.yml +26 -0
- data/vendor/redcloth/tests/images.yml +171 -0
- data/vendor/redcloth/tests/instiki.yml +39 -0
- data/vendor/redcloth/tests/links.yml +155 -0
- data/vendor/redcloth/tests/lists.yml +77 -0
- data/vendor/redcloth/tests/markdown.yml +218 -0
- data/vendor/redcloth/tests/poignant.yml +64 -0
- data/vendor/redcloth/tests/table.yml +198 -0
- data/vendor/redcloth/tests/textism.yml +406 -0
- metadata +432 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
= Unobtrusive Javascript for Rails Version 0.3.2
|
2
|
+
|
3
|
+
Please see www.ujs4rails.com for full documentation, articles and updates.
|
4
|
+
|
5
|
+
The Unobtrusive Javascript plugin for Rails allows you to attach Javascript behaviour and events to your page elements using pure Ruby, from within your controller or view, without clogging up your rendered HTML with Javascript - either inline or in the head of your document.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
The recommended way of installing the plugin is to take advantage of Subversion's svn:externals feature. From within your Rails app root, enter the following on the command line:
|
10
|
+
|
11
|
+
$ ./script/plugin install -x http://opensource.agileevolved.com/svn/root/rails_plugins/unobtrusive_javascript/tags/rel-0.2 unobtrusive_javascript
|
12
|
+
|
13
|
+
If you are upgrading from a previous version remember to update your applications javascripts with:
|
14
|
+
|
15
|
+
rake unobtrusive_javascript:install
|
16
|
+
|
17
|
+
Finally, add the necessary routes to config/routes.rb by adding:
|
18
|
+
|
19
|
+
UJS.routes
|
20
|
+
|
21
|
+
To the Routes.draw block.
|
22
|
+
|
23
|
+
== Including the necessary libraries and behaviours file
|
24
|
+
|
25
|
+
The only modification you need to make to your app is to add the following line somewhere in the head of your app's layout:
|
26
|
+
|
27
|
+
<%= javascript_include_tag 'prototype', :unobtrusive %>
|
28
|
+
|
29
|
+
You're now up and running with unobtrusive javascript functionality.
|
30
|
+
|
31
|
+
== Registering javascript behaviours
|
32
|
+
|
33
|
+
The plugin offers a simple, low-level function for attaching behaviours to elements of your page using the +register_js_behaviour+ function.
|
34
|
+
|
35
|
+
<%= apply_behaviour "#coolink:click", "alert('Hello world!')" %>
|
36
|
+
|
37
|
+
You can also pass a block to the function that lets you write your javascript behaviours using ruby:
|
38
|
+
|
39
|
+
<%= apply_behaviour "#sayhellothenfade:click" do |page, element, event|
|
40
|
+
page.alert "Hello, I'm gonna fade..."
|
41
|
+
element.visual_effect :fade
|
42
|
+
end %>
|
43
|
+
|
44
|
+
See the API documentation for more usage examples.
|
45
|
+
|
46
|
+
=== Rendering behaviours inside script blocks instead of an external file
|
47
|
+
|
48
|
+
By default, all unobtrusive behaviours will be rendered in an external javascript file, generated at runtime. Sometimes, you may want to embed the behaviours directly in a page, inside <tt>script</tt> tags. You can do this by passing the option <tt>:external => false</tt> to register_js_behaviour.
|
49
|
+
|
50
|
+
<%= apply_behaviour "#coolink:click", "alert('Hello world!')", :external => false %>
|
51
|
+
|
52
|
+
One of the main reasons to render javascript inside javascript tags instead of the external file is when you are embedding behaviours inside partials that are loaded into your page using AJAX. Because the external javascript file will already have been generated, any subsequent behaviours inside your AJAX-loaded partials will not register. For this reason the behaviours need to be rendered inside normal script tags. The unobtrusive_javascript plugin takes care of this for you automatically - any behaviours registered inside an AJAX-loaded partial will be rendered inside a script element without having to specify <tt>:external => false</tt> manually.
|
53
|
+
|
54
|
+
== Attaching behaviours directly to elements using Rails' tag generators
|
55
|
+
|
56
|
+
Rails comes with two built-in tag generator helpers - tag and content_tag. You can use these helpers to generate HTML elements and attach behaviour to them by directly specifying the events as part of the helpers' html options hash. The behaviours will be extracted and moved into the external behaviours file instead of being rendered inline.
|
57
|
+
|
58
|
+
<%= content_tag "div", "Click Me", :onclick => "alert('You clicked me')" %>
|
59
|
+
|
60
|
+
The full range of javascript events are available through this method.
|
61
|
+
|
62
|
+
The above functionality is achieved with a patch to Rails' tag_options function. Because of this patch, most of Rails' javascript/ajax helpers (or any helper that generates HTML using the tag_options function and that accepts an HTML options hash) will work in an unobtrusive fashion out of the box. The list of helpers that currently work unobtrusively include:
|
63
|
+
|
64
|
+
* link_to_remote
|
65
|
+
* link_to_function
|
66
|
+
* button_to_function
|
67
|
+
* form_remote_tag
|
68
|
+
* submit_to_remote
|
69
|
+
|
70
|
+
== Credits
|
71
|
+
|
72
|
+
The unobtrusive_javascript plugin is by Luke Redpath (http://www.lukeredpath.co.uk) and Dan Webb (http://www.vivabit.com/bollocks). The plugin also makes use of the Low Pro JavaScript library also by
|
73
|
+
Dan Webb, parts of which were heavily inspired by Justin Palmer's excellent event:Selectors (http://encytemedia.com/eventselectors/).
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
desc 'Default: run unit tests.'
|
7
|
+
task :default => :test
|
8
|
+
|
9
|
+
desc 'Test the unobtrusive_javascript plugin.'
|
10
|
+
Rake::TestTask.new(:test) do |t|
|
11
|
+
t.libs << 'lib'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the unobtrusive_javascript plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'UJS'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '--accessor=cattr_accessor'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Updates application with the necessary javascripts for unobtrusive_javascript.'
|
26
|
+
task :update_scripts do
|
27
|
+
FileUtils.cp Dir['assets/javascripts/*.js'], '../../../public/javascripts'
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Removes the javascripts for the plugin.'
|
31
|
+
task :remove_scripts do
|
32
|
+
FileUtils.rm %{lowpro.js}.collect { |f| "../../../public/javascripts/" + f }
|
33
|
+
end
|
@@ -0,0 +1,307 @@
|
|
1
|
+
LowPro = {};
|
2
|
+
LowPro.Version = '0.1';
|
3
|
+
|
4
|
+
// Adapted from DOM Ready extension by Dan Webb
|
5
|
+
// http://www.vivabit.com/bollocks/2006/06/21/a-dom-ready-extension-for-prototype
|
6
|
+
// which was based on work by Matthias Miller, Dean Edwards and John Resig
|
7
|
+
//
|
8
|
+
// Usage:
|
9
|
+
//
|
10
|
+
// Event.onReady(callbackFunction);
|
11
|
+
Object.extend(Event, {
|
12
|
+
_domReady : function() {
|
13
|
+
if (arguments.callee.done) return;
|
14
|
+
arguments.callee.done = true;
|
15
|
+
|
16
|
+
if (Event._timer) clearInterval(Event._timer);
|
17
|
+
|
18
|
+
Event._readyCallbacks.each(function(f) { f() });
|
19
|
+
Event._readyCallbacks = null;
|
20
|
+
|
21
|
+
},
|
22
|
+
onReady : function(f) {
|
23
|
+
if (!this._readyCallbacks) {
|
24
|
+
var domReady = this._domReady;
|
25
|
+
|
26
|
+
if (domReady.done) return f();
|
27
|
+
|
28
|
+
if (document.addEventListener)
|
29
|
+
document.addEventListener("DOMContentLoaded", domReady, false);
|
30
|
+
|
31
|
+
/*@cc_on @*/
|
32
|
+
/*@if (@_win32)
|
33
|
+
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
|
34
|
+
document.getElementById("__ie_onload").onreadystatechange = function() {
|
35
|
+
if (this.readyState == "complete") { domReady(); }
|
36
|
+
};
|
37
|
+
/*@end @*/
|
38
|
+
|
39
|
+
if (/WebKit/i.test(navigator.userAgent)) {
|
40
|
+
this._timer = setInterval(function() {
|
41
|
+
if (/loaded|complete/.test(document.readyState)) domReady();
|
42
|
+
}, 10);
|
43
|
+
}
|
44
|
+
|
45
|
+
Event.observe(window, 'load', domReady);
|
46
|
+
Event._readyCallbacks = [];
|
47
|
+
}
|
48
|
+
Event._readyCallbacks.push(f);
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
if (!Element.addMethods)
|
53
|
+
Element.addMethods = function(o) { Object.extend(Element.Methods, o) };
|
54
|
+
|
55
|
+
// Extend Element with observe and stopObserving.
|
56
|
+
Element.addMethods({
|
57
|
+
observe : function(el, event, callback) {
|
58
|
+
Event.observe(el, event, callback);
|
59
|
+
},
|
60
|
+
stopObserving : function(el, event, callback) {
|
61
|
+
Event.stopObserving(el, event, callback);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
65
|
+
// Replace out existing event observe code with Dean Edwards' addEvent
|
66
|
+
// http://dean.edwards.name/weblog/2005/10/add-event/
|
67
|
+
Object.extend(Event, {
|
68
|
+
observe : function(el, type, func) {
|
69
|
+
el = $(el);
|
70
|
+
if (!func.$$guid) func.$$guid = Event._guid++;
|
71
|
+
if (!el.events) el.events = {};
|
72
|
+
var handlers = el.events[type];
|
73
|
+
if (!handlers) {
|
74
|
+
handlers = el.events[type] = {};
|
75
|
+
if (el["on" + type]) {
|
76
|
+
handlers[0] = el["on" + type];
|
77
|
+
}
|
78
|
+
}
|
79
|
+
handlers[func.$$guid] = func;
|
80
|
+
el["on" + type] = Event._handleEvent;
|
81
|
+
|
82
|
+
if (!Event.observers) Event.observers = [];
|
83
|
+
Event.observers.push([el, name, func, false]);
|
84
|
+
},
|
85
|
+
stopObserving : function(el, type, func) {
|
86
|
+
if (el.events && el.events[type]) delete el.events[type][func.$$guid];
|
87
|
+
},
|
88
|
+
_handleEvent : function(e) {
|
89
|
+
var returnValue = true;
|
90
|
+
e = e || Event._fixEvent(window.event);
|
91
|
+
var handlers = this.events[e.type], el = $(this);
|
92
|
+
for (var i in handlers) {
|
93
|
+
el.$$handleEvent = handlers[i];
|
94
|
+
if (el.$$handleEvent(e) === false) returnValue = false;
|
95
|
+
}
|
96
|
+
return returnValue;
|
97
|
+
},
|
98
|
+
_fixEvent : function(e) {
|
99
|
+
e.preventDefault = Event._preventDefault;
|
100
|
+
e.stopPropagation = Event._stopPropagation;
|
101
|
+
return e;
|
102
|
+
},
|
103
|
+
_preventDefault : function() { this.returnValue = false },
|
104
|
+
_stopPropagation : function() { this.cancelBubble = true },
|
105
|
+
_guid : 1
|
106
|
+
});
|
107
|
+
|
108
|
+
// Allows you to trigger an event element.
|
109
|
+
Object.extend(Event, {
|
110
|
+
trigger : function(element, event, fakeEvent) {
|
111
|
+
element = $(element);
|
112
|
+
fakeEvent = fakeEvent || { type : event };
|
113
|
+
this.observers.each(function(cache) {
|
114
|
+
if (cache[0] == element && cache[1] == event)
|
115
|
+
cache[2].call(element, fakeEvent);
|
116
|
+
});
|
117
|
+
}
|
118
|
+
});
|
119
|
+
|
120
|
+
// Based on event:Selectors by Justin Palmer
|
121
|
+
// http://encytemedia.com/event-selectors/
|
122
|
+
//
|
123
|
+
// Usage:
|
124
|
+
//
|
125
|
+
// Event.addBehavior({
|
126
|
+
// "selector:event" : function(event) { /* event handler. this refers to the element. */ },
|
127
|
+
// "selector" : function() { /* runs function on dom ready. this refers to the element. */ }
|
128
|
+
// ...
|
129
|
+
// });
|
130
|
+
//
|
131
|
+
// Multiple calls will add to exisiting rules. Event.addBehavior.reassignAfterAjax and
|
132
|
+
// Event.addBehavior.autoTrigger can be adjusted to needs.
|
133
|
+
Event.addBehavior = function(rules) {
|
134
|
+
var ab = this.addBehavior;
|
135
|
+
Object.extend(ab.rules, rules);
|
136
|
+
|
137
|
+
if (ab.autoTrigger) {
|
138
|
+
this.onReady(ab.load.bind(ab));
|
139
|
+
}
|
140
|
+
|
141
|
+
Ajax.Responders.register({
|
142
|
+
onComplete : function() {
|
143
|
+
if (Event.addBehavior.reassignAfterAjax)
|
144
|
+
setTimeout(function() { ab.load() }, 10);
|
145
|
+
}
|
146
|
+
});
|
147
|
+
|
148
|
+
};
|
149
|
+
|
150
|
+
Object.extend(Event.addBehavior, {
|
151
|
+
rules : {}, cache : [],
|
152
|
+
reassignAfterAjax : true,
|
153
|
+
autoTrigger : true,
|
154
|
+
|
155
|
+
load : function() {
|
156
|
+
this.unload();
|
157
|
+
for (var selector in this.rules) {
|
158
|
+
var observer = this.rules[selector];
|
159
|
+
var sels = selector.split(',');
|
160
|
+
sels.each(function(sel) {
|
161
|
+
var parts = sel.split(/:(?=[a-z]+$)/), css = parts[0], event = parts[1];
|
162
|
+
$$(css).each(function(element) {
|
163
|
+
if (event) {
|
164
|
+
$(element).observe(event, observer);
|
165
|
+
Event.addBehavior.cache.push([element, event, observer]);
|
166
|
+
} else {
|
167
|
+
if (!element.$$assigned || !element.$$assigned.include(observer)) {
|
168
|
+
if (observer.attach) observer.attach(element);
|
169
|
+
else observer.call($(element));
|
170
|
+
element.$$assigned = element.$$assigned || [];
|
171
|
+
element.$$assigned.push(observer);
|
172
|
+
}
|
173
|
+
}
|
174
|
+
});
|
175
|
+
});
|
176
|
+
}
|
177
|
+
},
|
178
|
+
|
179
|
+
unload : function() {
|
180
|
+
this.cache.each(function(c) {
|
181
|
+
Event.stopObserving.apply(Event, c);
|
182
|
+
});
|
183
|
+
}
|
184
|
+
|
185
|
+
});
|
186
|
+
|
187
|
+
Event.observe(window, 'unload', Event.addBehavior.unload.bind(Event.addBehavior));
|
188
|
+
|
189
|
+
// Behaviors can be bound to elements to provide an object orientated way of controlling elements
|
190
|
+
// and their behavior. Use Behavior.create() to make a new behavior class then use attach() to
|
191
|
+
// glue it to an element. Each element then gets it's own instance of the behavior and any
|
192
|
+
// methods called onxxx are bound to the relevent event.
|
193
|
+
//
|
194
|
+
// Usage:
|
195
|
+
//
|
196
|
+
// var MyBehavior = Behavior.create({
|
197
|
+
// onmouseover : function() { this.element.addClassName('bong') }
|
198
|
+
// });
|
199
|
+
|
200
|
+
// Event.addBehavior({ 'a.rollover' : MyBehavior });
|
201
|
+
Behavior = {
|
202
|
+
create : function(members) {
|
203
|
+
var behavior = Class.create();
|
204
|
+
behavior.prototype.initialize = Prototype.K;
|
205
|
+
Object.extend(behavior.prototype, members);
|
206
|
+
Object.extend(behavior, Behavior.ClassMethods);
|
207
|
+
return behavior;
|
208
|
+
},
|
209
|
+
ClassMethods : {
|
210
|
+
attach : function(element) {
|
211
|
+
var bound = new this;
|
212
|
+
bound.element = $(element);
|
213
|
+
this._bindEvents(bound);
|
214
|
+
return bound;
|
215
|
+
},
|
216
|
+
_bindEvents : function(bound) {
|
217
|
+
for (var member in bound)
|
218
|
+
if (member.match(/^on(.+)/) && typeof bound[member] == 'function')
|
219
|
+
bound.element.observe(RegExp.$1, bound[member].bindAsEventListener(bound));
|
220
|
+
}
|
221
|
+
}
|
222
|
+
};
|
223
|
+
|
224
|
+
|
225
|
+
// Original code by Sylvian Zimmer
|
226
|
+
// http://www.sylvainzimmer.com/index.php/archives/2006/06/25/speeding-up-prototypes-selector/
|
227
|
+
// Optimises execution speed of the $$ function. Rewritten for readability by Justin Palmer.
|
228
|
+
//
|
229
|
+
// Turn off optimisation with LowPro.optimize$$ = false;
|
230
|
+
LowPro.SelectorLite = Class.create();
|
231
|
+
LowPro.SelectorLite.prototype = {
|
232
|
+
initialize: function(selectors) {
|
233
|
+
this.results = [];
|
234
|
+
this.selectors = [];
|
235
|
+
this.index = 0;
|
236
|
+
|
237
|
+
for(var i = selectors.length -1; i >= 0; i--) {
|
238
|
+
var params = { tag: '*', id: null, classes: [] };
|
239
|
+
var selector = selectors[i];
|
240
|
+
var needle = selector.length - 1;
|
241
|
+
|
242
|
+
do {
|
243
|
+
var id = selector.lastIndexOf("#");
|
244
|
+
var klass = selector.lastIndexOf(".");
|
245
|
+
var cursor = Math.max(id, klass);
|
246
|
+
|
247
|
+
if(cursor == -1) params.tag = selector.toUpperCase();
|
248
|
+
else if(id == -1 || klass == cursor) params.classes.push(selector.substring(klass + 1))
|
249
|
+
else if(!params.id) params.id = selector.substring(id + 1);
|
250
|
+
|
251
|
+
selector = selector.substring(0, cursor);
|
252
|
+
} while(cursor > 0);
|
253
|
+
this.selectors[i] = params;
|
254
|
+
}
|
255
|
+
|
256
|
+
},
|
257
|
+
|
258
|
+
get: function(root) {
|
259
|
+
this.findElements(root || document, this.index == (this.selectors.length - 1));
|
260
|
+
return this.results;
|
261
|
+
},
|
262
|
+
|
263
|
+
findElements: function(parent, descendant) {
|
264
|
+
var selector = this.selectors[this.index], results = [], element;
|
265
|
+
if(selector.id) {
|
266
|
+
element = $(selector.id);
|
267
|
+
if(element && (selector.tag == '*' || element.tagName == selector.tag) &&
|
268
|
+
(element.childOf(parent))) {
|
269
|
+
results = [element];
|
270
|
+
}
|
271
|
+
} else {
|
272
|
+
results = $A(parent.getElementsByTagName(selector.tag));
|
273
|
+
}
|
274
|
+
|
275
|
+
if(selector.classes.length == 1) {
|
276
|
+
results = results.select(function(target) {
|
277
|
+
return $(target).hasClassName(selector.classes[0]);
|
278
|
+
});
|
279
|
+
} else if(selector.classes.length > 1) {
|
280
|
+
results = results.select(function(target) {
|
281
|
+
var klasses = $(target).classNames();
|
282
|
+
return selector.classes.all(function(klass) {
|
283
|
+
return klasses.include(klass);
|
284
|
+
});
|
285
|
+
});
|
286
|
+
}
|
287
|
+
|
288
|
+
if(descendant) {
|
289
|
+
this.results = this.results.concat(results);
|
290
|
+
} else {
|
291
|
+
++this.index;
|
292
|
+
results.each(function(target) {
|
293
|
+
this.findElements(target, this.index == (this.selectors.length - 1));
|
294
|
+
}.bind(this));
|
295
|
+
}
|
296
|
+
}
|
297
|
+
}
|
298
|
+
|
299
|
+
LowPro.$$old=$$;
|
300
|
+
LowPro.optimize$$ = true;
|
301
|
+
|
302
|
+
function $$(a,b) {
|
303
|
+
if (LowPro.optimize$$ == false || b || a.indexOf("[")>=0)
|
304
|
+
return LowPro.$$old.apply(this, arguments);
|
305
|
+
return new LowPro.SelectorLite(a.split(/\s+/)).get();
|
306
|
+
}
|
307
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'actionview_helpers_patches'
|
2
|
+
require 'prototype_helper_patches'
|
3
|
+
require 'scriptaculous_helper_patches'
|
4
|
+
require 'asset_tag_helper_patches'
|
5
|
+
require 'tag_helper_patches'
|
6
|
+
require 'behaviour_caching'
|
7
|
+
require 'ujs'
|
8
|
+
|
9
|
+
# make plugin controllers and views available to app
|
10
|
+
config.load_paths += %W(#{UJS::PLUGIN_CONTROLLER_PATH})
|
11
|
+
Rails::Initializer.run(:set_load_path, config)
|
12
|
+
|
13
|
+
# add methods to action controller base
|
14
|
+
ActionController::Base.send(:include, UJS::ControllerMethods)
|
15
|
+
|
16
|
+
# load in the helpers and caching code
|
17
|
+
ActionController::Base.send(:helper, UJS::Helpers)
|
18
|
+
ActionController::Base.send(:include, UJS::BehaviourCaching)
|
19
|
+
|
20
|
+
# require the controller
|
21
|
+
require 'unobtrusive_javascript_controller'
|
@@ -0,0 +1 @@
|
|
1
|
+
`rake update_scripts`
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActionView::Helpers
|
2
|
+
def self.current_controller=(controller)
|
3
|
+
@@current_controller = controller
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.current_controller
|
7
|
+
@@current_controller
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class ActionView::Helpers::InstanceTag
|
12
|
+
include UJS::Helpers
|
13
|
+
|
14
|
+
def current_controller
|
15
|
+
ActionView::Helpers.current_controller
|
16
|
+
end
|
17
|
+
end
|