tabulous 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/CHANGELOG.rdoc +2 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +85 -0
- data/Rakefile +54 -0
- data/lib/generators/tabs/USAGE +1 -0
- data/lib/generators/tabs/tabs_generator.rb +13 -0
- data/lib/generators/tabs/templates/tabulous.rb +170 -0
- data/lib/tabulous.rb +11 -0
- data/lib/tabulous/css_scaffolding.rb +111 -0
- data/lib/tabulous/errors.rb +16 -0
- data/lib/tabulous/formatter.rb +278 -0
- data/lib/tabulous/helpers.rb +13 -0
- data/lib/tabulous/options.rb +37 -0
- data/lib/tabulous/railtie.rb +23 -0
- data/lib/tabulous/tab.rb +79 -0
- data/lib/tabulous/tabulous.rb +162 -0
- data/lib/tabulous/version.rb +3 -0
- data/lib/tasks/tabulous.rake +11 -0
- data/tabulous.gemspec +30 -0
- data/test/applications/main/.gitignore +3 -0
- data/test/applications/main/Gemfile +7 -0
- data/test/applications/main/Rakefile +7 -0
- data/test/applications/main/app/controllers/application_controller.rb +3 -0
- data/test/applications/main/app/controllers/galaxies_controller.rb +83 -0
- data/test/applications/main/app/controllers/home_controller.rb +4 -0
- data/test/applications/main/app/controllers/planets_controller.rb +83 -0
- data/test/applications/main/app/controllers/stars_controller.rb +83 -0
- data/test/applications/main/app/controllers/subtabs_controller.rb +8 -0
- data/test/applications/main/app/helpers/application_helper.rb +2 -0
- data/test/applications/main/app/helpers/galaxies_helper.rb +2 -0
- data/test/applications/main/app/helpers/planets_helper.rb +2 -0
- data/test/applications/main/app/helpers/stars_helper.rb +2 -0
- data/test/applications/main/app/models/galaxy.rb +2 -0
- data/test/applications/main/app/models/planet.rb +2 -0
- data/test/applications/main/app/models/star.rb +2 -0
- data/test/applications/main/app/views/galaxies/_form.html.erb +21 -0
- data/test/applications/main/app/views/galaxies/edit.html.erb +6 -0
- data/test/applications/main/app/views/galaxies/index.html.erb +23 -0
- data/test/applications/main/app/views/galaxies/new.html.erb +5 -0
- data/test/applications/main/app/views/galaxies/show.html.erb +10 -0
- data/test/applications/main/app/views/home/index.html.erb +3 -0
- data/test/applications/main/app/views/layouts/application.html.erb +16 -0
- data/test/applications/main/app/views/planets/_form.html.erb +21 -0
- data/test/applications/main/app/views/planets/edit.html.erb +6 -0
- data/test/applications/main/app/views/planets/index.html.erb +23 -0
- data/test/applications/main/app/views/planets/new.html.erb +5 -0
- data/test/applications/main/app/views/planets/show.html.erb +10 -0
- data/test/applications/main/app/views/stars/_form.html.erb +21 -0
- data/test/applications/main/app/views/stars/edit.html.erb +6 -0
- data/test/applications/main/app/views/stars/index.html.erb +23 -0
- data/test/applications/main/app/views/stars/new.html.erb +5 -0
- data/test/applications/main/app/views/stars/show.html.erb +10 -0
- data/test/applications/main/app/views/subtabs/one.html.erb +1 -0
- data/test/applications/main/app/views/subtabs/three.html.erb +1 -0
- data/test/applications/main/app/views/subtabs/two.html.erb +1 -0
- data/test/applications/main/config.ru +4 -0
- data/test/applications/main/config/application.rb +42 -0
- data/test/applications/main/config/boot.rb +13 -0
- data/test/applications/main/config/database.yml +22 -0
- data/test/applications/main/config/environment.rb +5 -0
- data/test/applications/main/config/environments/development.rb +26 -0
- data/test/applications/main/config/environments/production.rb +49 -0
- data/test/applications/main/config/environments/test.rb +35 -0
- data/test/applications/main/config/initializers/backtrace_silencers.rb +7 -0
- data/test/applications/main/config/initializers/inflections.rb +10 -0
- data/test/applications/main/config/initializers/mime_types.rb +5 -0
- data/test/applications/main/config/initializers/secret_token.rb +7 -0
- data/test/applications/main/config/initializers/session_store.rb +8 -0
- data/test/applications/main/config/initializers/tabulous.rb +156 -0
- data/test/applications/main/config/locales/en.yml +5 -0
- data/test/applications/main/config/routes.rb +69 -0
- data/test/applications/main/db/development.sqlite3 +0 -0
- data/test/applications/main/db/migrate/20110223232547_create_galaxies.rb +13 -0
- data/test/applications/main/db/migrate/20110223232552_create_stars.rb +13 -0
- data/test/applications/main/db/migrate/20110223232557_create_planets.rb +13 -0
- data/test/applications/main/db/production.sqlite3 +0 -0
- data/test/applications/main/db/schema.rb +33 -0
- data/test/applications/main/db/test.sqlite3 +0 -0
- data/test/applications/main/public/404.html +26 -0
- data/test/applications/main/public/422.html +26 -0
- data/test/applications/main/public/500.html +26 -0
- data/test/applications/main/public/favicon.ico +0 -0
- data/test/applications/main/public/javascripts/application.js +2 -0
- data/test/applications/main/public/javascripts/controls.js +965 -0
- data/test/applications/main/public/javascripts/dragdrop.js +974 -0
- data/test/applications/main/public/javascripts/effects.js +1123 -0
- data/test/applications/main/public/javascripts/prototype.js +6001 -0
- data/test/applications/main/public/javascripts/rails.js +175 -0
- data/test/applications/main/public/stylesheets/.gitkeep +0 -0
- data/test/applications/main/script/rails +6 -0
- data/test/applications/main/test/integration/actions_test.rb +79 -0
- data/test/applications/main/test/integration/active_tab_clickable_test.rb +86 -0
- data/test/applications/main/test/integration/always_render_subtabs_test.rb +84 -0
- data/test/applications/main/test/integration/css_no_scaffolding_test.rb +57 -0
- data/test/applications/main/test/integration/css_scaffolding_test.rb +67 -0
- data/test/applications/main/test/integration/display_text_test.rb +73 -0
- data/test/applications/main/test/integration/enabled_test.rb +80 -0
- data/test/applications/main/test/integration/html5_test.rb +64 -0
- data/test/applications/main/test/integration/main_tabs_test.rb +10 -0
- data/test/applications/main/test/integration/path_test.rb +81 -0
- data/test/applications/main/test/integration/visible_test.rb +80 -0
- data/test/applications/main/test/integration_test_helper.rb +6 -0
- data/test/applications/main/test/test_helper.rb +8 -0
- data/test/applications/main/test/unit/tabs_generator_test.rb +14 -0
- data/test/applications/simple_tabs/.gitignore +3 -0
- data/test/applications/simple_tabs/Gemfile +7 -0
- data/test/applications/simple_tabs/Rakefile +7 -0
- data/test/applications/simple_tabs/app/controllers/application_controller.rb +3 -0
- data/test/applications/simple_tabs/app/controllers/galaxies_controller.rb +83 -0
- data/test/applications/simple_tabs/app/controllers/home_controller.rb +4 -0
- data/test/applications/simple_tabs/app/controllers/planets_controller.rb +83 -0
- data/test/applications/simple_tabs/app/controllers/stars_controller.rb +83 -0
- data/test/applications/simple_tabs/app/helpers/application_helper.rb +2 -0
- data/test/applications/simple_tabs/app/helpers/galaxies_helper.rb +2 -0
- data/test/applications/simple_tabs/app/helpers/planets_helper.rb +2 -0
- data/test/applications/simple_tabs/app/helpers/stars_helper.rb +2 -0
- data/test/applications/simple_tabs/app/models/galaxy.rb +2 -0
- data/test/applications/simple_tabs/app/models/planet.rb +2 -0
- data/test/applications/simple_tabs/app/models/star.rb +2 -0
- data/test/applications/simple_tabs/app/views/galaxies/_form.html.erb +21 -0
- data/test/applications/simple_tabs/app/views/galaxies/edit.html.erb +6 -0
- data/test/applications/simple_tabs/app/views/galaxies/index.html.erb +23 -0
- data/test/applications/simple_tabs/app/views/galaxies/new.html.erb +5 -0
- data/test/applications/simple_tabs/app/views/galaxies/show.html.erb +10 -0
- data/test/applications/simple_tabs/app/views/home/index.html.erb +4 -0
- data/test/applications/simple_tabs/app/views/layouts/application.html.erb +16 -0
- data/test/applications/simple_tabs/app/views/planets/_form.html.erb +21 -0
- data/test/applications/simple_tabs/app/views/planets/edit.html.erb +6 -0
- data/test/applications/simple_tabs/app/views/planets/index.html.erb +23 -0
- data/test/applications/simple_tabs/app/views/planets/new.html.erb +5 -0
- data/test/applications/simple_tabs/app/views/planets/show.html.erb +10 -0
- data/test/applications/simple_tabs/app/views/stars/_form.html.erb +21 -0
- data/test/applications/simple_tabs/app/views/stars/edit.html.erb +6 -0
- data/test/applications/simple_tabs/app/views/stars/index.html.erb +23 -0
- data/test/applications/simple_tabs/app/views/stars/new.html.erb +5 -0
- data/test/applications/simple_tabs/app/views/stars/show.html.erb +10 -0
- data/test/applications/simple_tabs/config.ru +4 -0
- data/test/applications/simple_tabs/config/application.rb +42 -0
- data/test/applications/simple_tabs/config/boot.rb +13 -0
- data/test/applications/simple_tabs/config/database.yml +22 -0
- data/test/applications/simple_tabs/config/environment.rb +5 -0
- data/test/applications/simple_tabs/config/environments/development.rb +26 -0
- data/test/applications/simple_tabs/config/environments/production.rb +49 -0
- data/test/applications/simple_tabs/config/environments/test.rb +35 -0
- data/test/applications/simple_tabs/config/initializers/backtrace_silencers.rb +7 -0
- data/test/applications/simple_tabs/config/initializers/inflections.rb +10 -0
- data/test/applications/simple_tabs/config/initializers/mime_types.rb +5 -0
- data/test/applications/simple_tabs/config/initializers/secret_token.rb +7 -0
- data/test/applications/simple_tabs/config/initializers/session_store.rb +8 -0
- data/test/applications/simple_tabs/config/initializers/tabulous.rb +149 -0
- data/test/applications/simple_tabs/config/locales/en.yml +5 -0
- data/test/applications/simple_tabs/config/routes.rb +65 -0
- data/test/applications/simple_tabs/db/development.sqlite3 +0 -0
- data/test/applications/simple_tabs/db/migrate/20110220170240_create_galaxies.rb +13 -0
- data/test/applications/simple_tabs/db/migrate/20110220170245_create_stars.rb +13 -0
- data/test/applications/simple_tabs/db/migrate/20110220170250_create_planets.rb +13 -0
- data/test/applications/simple_tabs/db/production.sqlite3 +0 -0
- data/test/applications/simple_tabs/db/schema.rb +33 -0
- data/test/applications/simple_tabs/db/test.sqlite3 +0 -0
- data/test/applications/simple_tabs/public/404.html +26 -0
- data/test/applications/simple_tabs/public/422.html +26 -0
- data/test/applications/simple_tabs/public/500.html +26 -0
- data/test/applications/simple_tabs/public/favicon.ico +0 -0
- data/test/applications/simple_tabs/public/javascripts/application.js +2 -0
- data/test/applications/simple_tabs/public/javascripts/controls.js +965 -0
- data/test/applications/simple_tabs/public/javascripts/dragdrop.js +974 -0
- data/test/applications/simple_tabs/public/javascripts/effects.js +1123 -0
- data/test/applications/simple_tabs/public/javascripts/prototype.js +6001 -0
- data/test/applications/simple_tabs/public/javascripts/rails.js +175 -0
- data/test/applications/simple_tabs/public/stylesheets/.gitkeep +0 -0
- data/test/applications/simple_tabs/script/rails +6 -0
- data/test/applications/simple_tabs/test/integration/simple_tabs_test.rb +34 -0
- data/test/applications/simple_tabs/test/integration_test_helper.rb +6 -0
- data/test/applications/simple_tabs/test/test_helper.rb +8 -0
- data/test/applications/subtabs/.gitignore +3 -0
- data/test/applications/subtabs/Gemfile +7 -0
- data/test/applications/subtabs/Rakefile +7 -0
- data/test/applications/subtabs/app/controllers/application_controller.rb +3 -0
- data/test/applications/subtabs/app/controllers/exoplanets_controller.rb +83 -0
- data/test/applications/subtabs/app/controllers/galaxies/elliptical_galaxies_controller.rb +85 -0
- data/test/applications/subtabs/app/controllers/galaxies/lenticular_galaxies_controller.rb +85 -0
- data/test/applications/subtabs/app/controllers/galaxies/spiral_galaxies_controller.rb +85 -0
- data/test/applications/subtabs/app/controllers/home_controller.rb +4 -0
- data/test/applications/subtabs/app/controllers/misc_controller.rb +15 -0
- data/test/applications/subtabs/app/controllers/rogue_planets_controller.rb +83 -0
- data/test/applications/subtabs/app/controllers/stars_controller.rb +83 -0
- data/test/applications/subtabs/app/helpers/application_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/elliptical_galaxies_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/exoplanets_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/lenticular_galaxies_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/rogue_planets_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/spiral_galaxies_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/stars_helper.rb +2 -0
- data/test/applications/subtabs/app/models/elliptical_galaxy.rb +2 -0
- data/test/applications/subtabs/app/models/exoplanet.rb +2 -0
- data/test/applications/subtabs/app/models/lenticular_galaxy.rb +2 -0
- data/test/applications/subtabs/app/models/rogue_planet.rb +2 -0
- data/test/applications/subtabs/app/models/spiral_galaxy.rb +2 -0
- data/test/applications/subtabs/app/models/star.rb +2 -0
- data/test/applications/subtabs/app/views/exoplanets/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/exoplanets/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/exoplanets/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/exoplanets/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/exoplanets/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/home/index.html.erb +14 -0
- data/test/applications/subtabs/app/views/layouts/application.html.erb +21 -0
- data/test/applications/subtabs/app/views/misc/always_enabled.html.erb +4 -0
- data/test/applications/subtabs/app/views/misc/always_visible.html.erb +4 -0
- data/test/applications/subtabs/app/views/rogue_planets/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/rogue_planets/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/rogue_planets/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/rogue_planets/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/rogue_planets/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/stars/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/stars/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/stars/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/stars/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/stars/show.html.erb +10 -0
- data/test/applications/subtabs/config.ru +4 -0
- data/test/applications/subtabs/config/application.rb +42 -0
- data/test/applications/subtabs/config/boot.rb +13 -0
- data/test/applications/subtabs/config/database.yml +22 -0
- data/test/applications/subtabs/config/environment.rb +5 -0
- data/test/applications/subtabs/config/environments/development.rb +26 -0
- data/test/applications/subtabs/config/environments/production.rb +49 -0
- data/test/applications/subtabs/config/environments/test.rb +35 -0
- data/test/applications/subtabs/config/initializers/backtrace_silencers.rb +7 -0
- data/test/applications/subtabs/config/initializers/inflections.rb +10 -0
- data/test/applications/subtabs/config/initializers/mime_types.rb +5 -0
- data/test/applications/subtabs/config/initializers/secret_token.rb +7 -0
- data/test/applications/subtabs/config/initializers/session_store.rb +8 -0
- data/test/applications/subtabs/config/initializers/tabulous.rb +167 -0
- data/test/applications/subtabs/config/locales/en.yml +5 -0
- data/test/applications/subtabs/config/routes.rb +74 -0
- data/test/applications/subtabs/db/development.sqlite3 +0 -0
- data/test/applications/subtabs/db/migrate/20110223220628_create_galaxies.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110223220634_create_stars.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110223220640_create_planets.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190125_create_rogue_planets.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190131_create_exoplanets.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190532_create_spiral_galaxies.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190537_create_lenticular_galaxies.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190543_create_elliptical_galaxies.rb +13 -0
- data/test/applications/subtabs/db/production.sqlite3 +0 -0
- data/test/applications/subtabs/db/schema.rb +63 -0
- data/test/applications/subtabs/db/test.sqlite3 +0 -0
- data/test/applications/subtabs/public/404.html +26 -0
- data/test/applications/subtabs/public/422.html +26 -0
- data/test/applications/subtabs/public/500.html +26 -0
- data/test/applications/subtabs/public/favicon.ico +0 -0
- data/test/applications/subtabs/public/javascripts/application.js +2 -0
- data/test/applications/subtabs/public/javascripts/controls.js +965 -0
- data/test/applications/subtabs/public/javascripts/dragdrop.js +974 -0
- data/test/applications/subtabs/public/javascripts/effects.js +1123 -0
- data/test/applications/subtabs/public/javascripts/prototype.js +6001 -0
- data/test/applications/subtabs/public/javascripts/rails.js +175 -0
- data/test/applications/subtabs/public/stylesheets/.gitkeep +0 -0
- data/test/applications/subtabs/public/stylesheets/application.css +49 -0
- data/test/applications/subtabs/public/stylesheets/reset.css +48 -0
- data/test/applications/subtabs/script/rails +6 -0
- data/test/applications/subtabs/test/integration/subtabs_test.rb +67 -0
- data/test/applications/subtabs/test/integration_test_helper.rb +6 -0
- data/test/applications/subtabs/test/test_helper.rb +8 -0
- data/test/test_application_gemfile.rb +14 -0
- data/test/test_application_integration_test_helper.rb +89 -0
- data/test/test_application_test_helper.rb +11 -0
- data/test/test_initializers/empty +0 -0
- data/test/test_initializers/expected +55 -0
- data/test/test_initializers/random_horizontal_whitespace +55 -0
- data/test/test_initializers/random_vertical_whitespace +102 -0
- data/test/test_initializers/text +144 -0
- data/test/test_initializers/trailing_comments +55 -0
- data/test/unit_test_helper.rb +13 -0
- data/test/units/tabulous_formatter_test.rb +69 -0
- metadata +466 -0
@@ -0,0 +1,175 @@
|
|
1
|
+
(function() {
|
2
|
+
// Technique from Juriy Zaytsev
|
3
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
+
function isEventSupported(eventName) {
|
5
|
+
var el = document.createElement('div');
|
6
|
+
eventName = 'on' + eventName;
|
7
|
+
var isSupported = (eventName in el);
|
8
|
+
if (!isSupported) {
|
9
|
+
el.setAttribute(eventName, 'return;');
|
10
|
+
isSupported = typeof el[eventName] == 'function';
|
11
|
+
}
|
12
|
+
el = null;
|
13
|
+
return isSupported;
|
14
|
+
}
|
15
|
+
|
16
|
+
function isForm(element) {
|
17
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
18
|
+
}
|
19
|
+
|
20
|
+
function isInput(element) {
|
21
|
+
if (Object.isElement(element)) {
|
22
|
+
var name = element.nodeName.toUpperCase()
|
23
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
24
|
+
}
|
25
|
+
else return false
|
26
|
+
}
|
27
|
+
|
28
|
+
var submitBubbles = isEventSupported('submit'),
|
29
|
+
changeBubbles = isEventSupported('change')
|
30
|
+
|
31
|
+
if (!submitBubbles || !changeBubbles) {
|
32
|
+
// augment the Event.Handler class to observe custom events when needed
|
33
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
+
function(init, element, eventName, selector, callback) {
|
35
|
+
init(element, eventName, selector, callback)
|
36
|
+
// is the handler being attached to an element that doesn't support this event?
|
37
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
+
// "submit" => "emulated:submit"
|
40
|
+
this.eventName = 'emulated:' + this.eventName
|
41
|
+
}
|
42
|
+
}
|
43
|
+
)
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!submitBubbles) {
|
47
|
+
// discover forms on the page by observing focus events which always bubble
|
48
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
+
// special handler for the real "submit" event (one-time operation)
|
50
|
+
if (!form.retrieve('emulated:submit')) {
|
51
|
+
form.on('submit', function(submitEvent) {
|
52
|
+
var emulated = form.fire('emulated:submit', submitEvent, true)
|
53
|
+
// if custom event received preventDefault, cancel the real one too
|
54
|
+
if (emulated.returnValue === false) submitEvent.preventDefault()
|
55
|
+
})
|
56
|
+
form.store('emulated:submit', true)
|
57
|
+
}
|
58
|
+
})
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!changeBubbles) {
|
62
|
+
// discover form inputs on the page
|
63
|
+
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
64
|
+
// special handler for real "change" events
|
65
|
+
if (!input.retrieve('emulated:change')) {
|
66
|
+
input.on('change', function(changeEvent) {
|
67
|
+
input.fire('emulated:change', changeEvent, true)
|
68
|
+
})
|
69
|
+
input.store('emulated:change', true)
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
function handleRemote(element) {
|
75
|
+
var method, url, params;
|
76
|
+
|
77
|
+
var event = element.fire("ajax:before");
|
78
|
+
if (event.stopped) return false;
|
79
|
+
|
80
|
+
if (element.tagName.toLowerCase() === 'form') {
|
81
|
+
method = element.readAttribute('method') || 'post';
|
82
|
+
url = element.readAttribute('action');
|
83
|
+
params = element.serialize();
|
84
|
+
} else {
|
85
|
+
method = element.readAttribute('data-method') || 'get';
|
86
|
+
url = element.readAttribute('href');
|
87
|
+
params = {};
|
88
|
+
}
|
89
|
+
|
90
|
+
new Ajax.Request(url, {
|
91
|
+
method: method,
|
92
|
+
parameters: params,
|
93
|
+
evalScripts: true,
|
94
|
+
|
95
|
+
onComplete: function(request) { element.fire("ajax:complete", request); },
|
96
|
+
onSuccess: function(request) { element.fire("ajax:success", request); },
|
97
|
+
onFailure: function(request) { element.fire("ajax:failure", request); }
|
98
|
+
});
|
99
|
+
|
100
|
+
element.fire("ajax:after");
|
101
|
+
}
|
102
|
+
|
103
|
+
function handleMethod(element) {
|
104
|
+
var method = element.readAttribute('data-method'),
|
105
|
+
url = element.readAttribute('href'),
|
106
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
107
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
108
|
+
|
109
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
110
|
+
element.parentNode.insert(form);
|
111
|
+
|
112
|
+
if (method !== 'post') {
|
113
|
+
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
114
|
+
form.insert(field);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (csrf_param) {
|
118
|
+
var param = csrf_param.readAttribute('content'),
|
119
|
+
token = csrf_token.readAttribute('content'),
|
120
|
+
field = new Element('input', { type: 'hidden', name: param, value: token });
|
121
|
+
form.insert(field);
|
122
|
+
}
|
123
|
+
|
124
|
+
form.submit();
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
document.on("click", "*[data-confirm]", function(event, element) {
|
129
|
+
var message = element.readAttribute('data-confirm');
|
130
|
+
if (!confirm(message)) event.stop();
|
131
|
+
});
|
132
|
+
|
133
|
+
document.on("click", "a[data-remote]", function(event, element) {
|
134
|
+
if (event.stopped) return;
|
135
|
+
handleRemote(element);
|
136
|
+
event.stop();
|
137
|
+
});
|
138
|
+
|
139
|
+
document.on("click", "a[data-method]", function(event, element) {
|
140
|
+
if (event.stopped) return;
|
141
|
+
handleMethod(element);
|
142
|
+
event.stop();
|
143
|
+
});
|
144
|
+
|
145
|
+
document.on("submit", function(event) {
|
146
|
+
var element = event.findElement(),
|
147
|
+
message = element.readAttribute('data-confirm');
|
148
|
+
if (message && !confirm(message)) {
|
149
|
+
event.stop();
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
|
153
|
+
var inputs = element.select("input[type=submit][data-disable-with]");
|
154
|
+
inputs.each(function(input) {
|
155
|
+
input.disabled = true;
|
156
|
+
input.writeAttribute('data-original-value', input.value);
|
157
|
+
input.value = input.readAttribute('data-disable-with');
|
158
|
+
});
|
159
|
+
|
160
|
+
var element = event.findElement("form[data-remote]");
|
161
|
+
if (element) {
|
162
|
+
handleRemote(element);
|
163
|
+
event.stop();
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
document.on("ajax:after", "form", function(event, element) {
|
168
|
+
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
169
|
+
inputs.each(function(input) {
|
170
|
+
input.value = input.readAttribute('data-original-value');
|
171
|
+
input.removeAttribute('data-original-value');
|
172
|
+
input.disabled = false;
|
173
|
+
});
|
174
|
+
});
|
175
|
+
})();
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require File.expand_path("../integration_test_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class ActionsTest < ActionController::IntegrationTest
|
4
|
+
|
5
|
+
def setup
|
6
|
+
use_initializer %Q{
|
7
|
+
Tabulous.setup do |config|
|
8
|
+
|
9
|
+
config.tabs = [
|
10
|
+
#------------------------------------------------------------------------------------------------------#
|
11
|
+
# TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #
|
12
|
+
#------------------------------------------------------------------------------------------------------#
|
13
|
+
[ :home_tab , 'Explanation' , "/" , true , true ],
|
14
|
+
[ :galaxies_tab , 'Galaxies' , "/galaxies" , true , true ],
|
15
|
+
[ :stars_tab , 'Stars' , "/stars" , true , true ],
|
16
|
+
[ :planets_tab , 'Planets' , "/planets" , true , true ],
|
17
|
+
[ :subtabs_tab , 'Subtabs' , "/subtabs/one" , true , true ],
|
18
|
+
[ :one_subtab , 'One' , "/subtabs/one" , true , true ],
|
19
|
+
[ :two_subtab , 'Two' , "/subtabs/two" , true , true ],
|
20
|
+
[ :three_subtab , 'Three' , "/subtabs/three" , true , true ],
|
21
|
+
#------------------------------------------------------------------------------------------------------#
|
22
|
+
# TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #
|
23
|
+
#------------------------------------------------------------------------------------------------------#
|
24
|
+
]
|
25
|
+
|
26
|
+
config.actions = [
|
27
|
+
#-------------------------------------------------------------#
|
28
|
+
# CONTROLLER | ACTION | TAB #
|
29
|
+
#-------------------------------------------------------------#
|
30
|
+
[ :home , :index , :home_tab ],
|
31
|
+
[ :galaxies , :all_actions , :galaxies_tab ],
|
32
|
+
[ :stars , :all_actions , :stars_tab ],
|
33
|
+
[ :planets , :all_actions , :planets_tab ],
|
34
|
+
[ :subtabs , :one , :one_subtab ],
|
35
|
+
[ :subtabs , :two , :two_subtab ],
|
36
|
+
[ :subtabs , :three , :three_subtab ],
|
37
|
+
#-------------------------------------------------------------#
|
38
|
+
# CONTROLLER | ACTION | TAB #
|
39
|
+
#-------------------------------------------------------------#
|
40
|
+
]
|
41
|
+
|
42
|
+
config.css.scaffolding = true
|
43
|
+
|
44
|
+
end
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
test "tab actions" do
|
49
|
+
visit '/'
|
50
|
+
assert page.has_content?('This tests tabulous in all sorts of configurations.')
|
51
|
+
assert_tab_active 'Explanation'
|
52
|
+
click_link 'Galaxies'
|
53
|
+
assert page.has_content?('Listing galaxies')
|
54
|
+
assert_tab_active 'Galaxies'
|
55
|
+
click_link 'New Galaxy'
|
56
|
+
assert page.has_content?('New galaxy')
|
57
|
+
assert_tab_active 'Galaxies'
|
58
|
+
click_link 'Planets'
|
59
|
+
assert page.has_content?('Listing planets')
|
60
|
+
assert_tab_active 'Planets'
|
61
|
+
end
|
62
|
+
|
63
|
+
test "subtab actions" do
|
64
|
+
visit '/'
|
65
|
+
click_link 'Subtabs'
|
66
|
+
assert page.has_content?('Subtab #1')
|
67
|
+
assert_tab_active 'Subtabs'
|
68
|
+
assert_subtab_active 'One'
|
69
|
+
click_link 'Two'
|
70
|
+
assert page.has_content?('Subtab #2')
|
71
|
+
assert_tab_active 'Subtabs'
|
72
|
+
assert_subtab_active 'Two'
|
73
|
+
click_link 'Three'
|
74
|
+
assert page.has_content?('Subtab #3')
|
75
|
+
assert_tab_active 'Subtabs'
|
76
|
+
assert_subtab_active 'Three'
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require File.expand_path("../integration_test_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class ActiveTabClickableTest < ActionController::IntegrationTest
|
4
|
+
|
5
|
+
def init(active_tab_clickable)
|
6
|
+
use_initializer %Q{
|
7
|
+
Tabulous.setup do |config|
|
8
|
+
|
9
|
+
config.tabs = [
|
10
|
+
#------------------------------------------------------------------------------------------------------#
|
11
|
+
# TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #
|
12
|
+
#------------------------------------------------------------------------------------------------------#
|
13
|
+
[ :home_tab , 'Explanation' , "/" , true , true ],
|
14
|
+
[ :galaxies_tab , 'Galaxies' , "/galaxies" , true , true ],
|
15
|
+
[ :stars_tab , 'Stars' , "/stars" , true , true ],
|
16
|
+
[ :planets_tab , 'Planets' , "/planets" , true , true ],
|
17
|
+
[ :subtabs_tab , 'Subtabs' , "/subtabs/one" , true , true ],
|
18
|
+
[ :one_subtab , 'One' , "/subtabs/one" , true , true ],
|
19
|
+
[ :two_subtab , 'Two' , "/subtabs/two" , true , true ],
|
20
|
+
[ :three_subtab , 'Three' , "/subtabs/three" , true , true ],
|
21
|
+
#------------------------------------------------------------------------------------------------------#
|
22
|
+
# TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #
|
23
|
+
#------------------------------------------------------------------------------------------------------#
|
24
|
+
]
|
25
|
+
|
26
|
+
config.actions = [
|
27
|
+
#-------------------------------------------------------------#
|
28
|
+
# CONTROLLER | ACTION | TAB #
|
29
|
+
#-------------------------------------------------------------#
|
30
|
+
[ :home , :all_actions , :home_tab ],
|
31
|
+
[ :galaxies , :all_actions , :galaxies_tab ],
|
32
|
+
[ :stars , :all_actions , :stars_tab ],
|
33
|
+
[ :planets , :all_actions , :planets_tab ],
|
34
|
+
[ :subtabs , :one , :one_subtab ],
|
35
|
+
[ :subtabs , :two , :two_subtab ],
|
36
|
+
[ :subtabs , :three , :three_subtab ],
|
37
|
+
#-------------------------------------------------------------#
|
38
|
+
# CONTROLLER | ACTION | TAB #
|
39
|
+
#-------------------------------------------------------------#
|
40
|
+
]
|
41
|
+
|
42
|
+
config.active_tab_clickable = #{active_tab_clickable}
|
43
|
+
|
44
|
+
end
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def assert_tab_clickable(text)
|
49
|
+
result = page.all('#tabs li a', :text => text)
|
50
|
+
assert !result.empty?
|
51
|
+
end
|
52
|
+
|
53
|
+
def assert_tab_not_clickable(text)
|
54
|
+
link = page.all('#tabs li a', :text => text)
|
55
|
+
span = page.all('#tabs li span', :text => text)
|
56
|
+
assert !span.empty?
|
57
|
+
assert link.empty?
|
58
|
+
end
|
59
|
+
|
60
|
+
test "active tab clickable" do
|
61
|
+
init(true)
|
62
|
+
visit '/'
|
63
|
+
assert_tab_active 'Explanation'
|
64
|
+
assert_tab_clickable 'Explanation'
|
65
|
+
click_link 'Galaxies'
|
66
|
+
assert_tab_active 'Galaxies'
|
67
|
+
assert_tab_clickable 'Galaxies'
|
68
|
+
click_link 'Subtabs'
|
69
|
+
assert_tab_active 'Subtabs'
|
70
|
+
assert_tab_clickable 'Subtabs'
|
71
|
+
end
|
72
|
+
|
73
|
+
test "active tab not clickable" do
|
74
|
+
init(false)
|
75
|
+
visit '/'
|
76
|
+
assert_tab_active 'Explanation'
|
77
|
+
assert_tab_not_clickable 'Explanation'
|
78
|
+
click_link 'Galaxies'
|
79
|
+
assert_tab_active 'Galaxies'
|
80
|
+
assert_tab_not_clickable 'Galaxies'
|
81
|
+
click_link 'Subtabs'
|
82
|
+
assert_tab_active 'Subtabs'
|
83
|
+
assert_tab_not_clickable 'Subtabs'
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.expand_path("../integration_test_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class AlwaysRenderSubtabsTest < ActionController::IntegrationTest
|
4
|
+
|
5
|
+
def init(always_render_subtabs)
|
6
|
+
use_initializer %Q{
|
7
|
+
Tabulous.setup do |config|
|
8
|
+
|
9
|
+
config.tabs = [
|
10
|
+
#------------------------------------------------------------------------------------------------------#
|
11
|
+
# TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #
|
12
|
+
#------------------------------------------------------------------------------------------------------#
|
13
|
+
[ :home_tab , 'Explanation' , "/" , true , true ],
|
14
|
+
[ :galaxies_tab , 'Galaxies' , "/galaxies" , true , true ],
|
15
|
+
[ :stars_tab , 'Stars' , "/stars" , true , true ],
|
16
|
+
[ :planets_tab , 'Planets' , "/planets" , true , true ],
|
17
|
+
[ :subtabs_tab , 'Subtabs' , "/subtabs/one" , true , true ],
|
18
|
+
[ :one_subtab , 'One' , "/subtabs/one" , true , true ],
|
19
|
+
[ :two_subtab , 'Two' , "/subtabs/two" , true , true ],
|
20
|
+
[ :three_subtab , 'Three' , "/subtabs/three" , true , true ],
|
21
|
+
#------------------------------------------------------------------------------------------------------#
|
22
|
+
# TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #
|
23
|
+
#------------------------------------------------------------------------------------------------------#
|
24
|
+
]
|
25
|
+
|
26
|
+
config.actions = [
|
27
|
+
#-------------------------------------------------------------#
|
28
|
+
# CONTROLLER | ACTION | TAB #
|
29
|
+
#-------------------------------------------------------------#
|
30
|
+
[ :home , :all_actions , :home_tab ],
|
31
|
+
[ :galaxies , :all_actions , :galaxies_tab ],
|
32
|
+
[ :stars , :all_actions , :stars_tab ],
|
33
|
+
[ :planets , :all_actions , :planets_tab ],
|
34
|
+
[ :subtabs , :one , :one_subtab ],
|
35
|
+
[ :subtabs , :two , :two_subtab ],
|
36
|
+
[ :subtabs , :three , :three_subtab ],
|
37
|
+
#-------------------------------------------------------------#
|
38
|
+
# CONTROLLER | ACTION | TAB #
|
39
|
+
#-------------------------------------------------------------#
|
40
|
+
]
|
41
|
+
|
42
|
+
config.always_render_subtabs = #{always_render_subtabs}
|
43
|
+
|
44
|
+
end
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def assert_subtabs
|
49
|
+
assert page.has_css?('#subtabs')
|
50
|
+
end
|
51
|
+
|
52
|
+
def assert_no_subtabs
|
53
|
+
assert !page.has_css?('#subtabs')
|
54
|
+
end
|
55
|
+
|
56
|
+
test "always render subtabs" do
|
57
|
+
init(true)
|
58
|
+
visit '/'
|
59
|
+
assert_subtabs
|
60
|
+
click_link 'Galaxies'
|
61
|
+
assert_subtabs
|
62
|
+
click_link 'Stars'
|
63
|
+
assert_subtabs
|
64
|
+
click_link 'Planets'
|
65
|
+
assert_subtabs
|
66
|
+
click_link 'Subtabs'
|
67
|
+
assert_subtabs
|
68
|
+
end
|
69
|
+
|
70
|
+
test "don't always render subtabs" do
|
71
|
+
init(false)
|
72
|
+
visit '/'
|
73
|
+
assert_no_subtabs
|
74
|
+
click_link 'Galaxies'
|
75
|
+
assert_no_subtabs
|
76
|
+
click_link 'Stars'
|
77
|
+
assert_no_subtabs
|
78
|
+
click_link 'Planets'
|
79
|
+
assert_no_subtabs
|
80
|
+
click_link 'Subtabs'
|
81
|
+
assert_subtabs
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.expand_path("../integration_test_helper", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
class CssNoScaffoldingTest < ActionController::IntegrationTest
|
4
|
+
|
5
|
+
def setup
|
6
|
+
use_initializer %Q{
|
7
|
+
Tabulous.setup do |config|
|
8
|
+
|
9
|
+
config.tabs = [
|
10
|
+
#------------------------------------------------------------------------------------------------------#
|
11
|
+
# TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #
|
12
|
+
#------------------------------------------------------------------------------------------------------#
|
13
|
+
[ :home_tab , 'Explanation' , "/" , true , true ],
|
14
|
+
[ :galaxies_tab , 'Galaxies' , "/galaxies" , true , true ],
|
15
|
+
[ :stars_tab , 'Stars' , "/stars" , true , true ],
|
16
|
+
[ :planets_tab , 'Planets' , "/planets" , true , true ],
|
17
|
+
[ :subtabs_tab , 'Subtabs' , "/subtabs/one" , true , true ],
|
18
|
+
[ :one_subtab , 'One' , "/subtabs/one" , true , true ],
|
19
|
+
[ :two_subtab , 'Two' , "/subtabs/two" , true , true ],
|
20
|
+
[ :three_subtab , 'Three' , "/subtabs/three" , true , true ],
|
21
|
+
#------------------------------------------------------------------------------------------------------#
|
22
|
+
# TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #
|
23
|
+
#------------------------------------------------------------------------------------------------------#
|
24
|
+
]
|
25
|
+
|
26
|
+
config.actions = [
|
27
|
+
#-------------------------------------------------------------#
|
28
|
+
# CONTROLLER | ACTION | TAB #
|
29
|
+
#-------------------------------------------------------------#
|
30
|
+
[ :home , :all_actions , :home_tab ],
|
31
|
+
[ :galaxies , :all_actions , :galaxies_tab ],
|
32
|
+
[ :stars , :all_actions , :stars_tab ],
|
33
|
+
[ :planets , :all_actions , :planets_tab ],
|
34
|
+
[ :subtabs , :one , :one_subtab ],
|
35
|
+
[ :subtabs , :two , :two_subtab ],
|
36
|
+
[ :subtabs , :three , :three_subtab ],
|
37
|
+
#-------------------------------------------------------------#
|
38
|
+
# CONTROLLER | ACTION | TAB #
|
39
|
+
#-------------------------------------------------------------#
|
40
|
+
]
|
41
|
+
|
42
|
+
end
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
test "works without css scaffolding" do
|
47
|
+
visit '/'
|
48
|
+
assert_tab_active 'Explanation'
|
49
|
+
click_link 'Galaxies'
|
50
|
+
assert page.has_content?('Listing galaxies')
|
51
|
+
assert_tab_active 'Galaxies'
|
52
|
+
click_link 'Planets'
|
53
|
+
assert page.has_content?('Listing planets')
|
54
|
+
assert_tab_active 'Planets'
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|